Roblox Forum banner
1 - 3 of 3 Posts

·
Registered
Joined
·
186 Posts
Discussion Starter · #1 · (Edited)
i have a death message system and it won't work, I surrounded the error with --error, example: --error if "message" --error
Code:
--Messages
local DeathMessages =  "got owned by a rake"   --error "tried befriending a rake but died" --error   "got ganged up on by some rakes"    "got uno reverse carded by a rake"    "raged too hard"     "got sent to brazil by a rake"     "gave up the ghost"     "got ended by a rake"     "got set to nil"     "LOSE, RAKE WIN"     "got roasted by a rake"


--Actual script
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if script:FindFirstChild("SendDeathMessage") and script:FindFirstChild("DeathMessage") then
script:FindFirstChild("SendDeathMessage").Parent = game.ReplicatedStorage
script:FindFirstChild("DeathMessage").Parent = game.StarterGui
if player.Character:FindFirstChild("Humanoid") then
local hum = player.Character:FindFirstChild("Humanoid")
hum.Died:Connect(function()
local DeathMessage = DeathMessages[math.random(1,#DeathMessages)]
local Users = game.Players:GetChildren()
for i, User in pairs(Users) do
if game.ReplicatedStorage:FindFirstChild("SendDeathMessage") then
game.ReplicatedStorage.SendDeathMessage:InvokeClient(User, player.Name .. " " .. DeathMessage)
end
end
end)
end
elseif game.ReplicatedStorage:FindFirstChild("SendDeathMessage") and game.StarterGui:FindFirstChild("DeathMessage") then
if player.Character:FindFirstChild("Humanoid") then
local hum = player.Character:FindFirstChild("Humanoid")
hum.Died:Connect(function()
local DeathMessage = DeathMessages[math.random(1,#DeathMessages)]
local Users = game.Players:GetChildren()
for i, User in pairs(Users) do
if game.ReplicatedStorage:FindFirstChild("SendDeathMessage") then
game.ReplicatedStorage.SendDeathMessage:InvokeClient(User, player.Name .. " " .. DeathMessage)
end
end
end)
end  
end
end)
end)
what am I doing wrong here
 

·
Premium member
Joined
·
215 Posts
Code:
--Messages
local DeathMessages = {
    "got owned by a rake",
    "tried befriending a rake but died",
    "got ganged up on by some rakes",
    "got uno reverse carded by a rake",
    "got uno reverse carded by a rake",
    "raged too hard",
    "got sent to brazil by a rake",
    "gave up the ghost",
    "got ended by a rake",
    "got set to nil",
    "LOSE, RAKE WIN",
    "got roasted by a rake"
    
    
}

--Actual script
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        if script:FindFirstChild("SendDeathMessage") ~= nil and script:FindFirstChild("DeathMessage") ~= nil then
            script:FindFirstChild("SendDeathMessage").Parent = game.ReplicatedStorage
            script:FindFirstChild("DeathMessage").Parent = game.StarterGui
            if player.Character:FindFirstChild("Humanoid") ~= nil then
                local hum = player.Character:FindFirstChild("Humanoid")
                hum.Died:Connect(function()
                    local DeathMessage = DeathMessages[math.random(1,#DeathMessages)]
                    local Users = game.Players:GetPlayers()
                    for i, User in pairs(Users) do
                        if game.ReplicatedStorage:FindFirstChild("SendDeathMessage") ~= nil then
                            game.ReplicatedStorage.SendDeathMessage:InvokeClient(User, player.Name .. " " .. DeathMessage)
                        end
                    end
                end)
            end
        elseif game.ReplicatedStorage:FindFirstChild("SendDeathMessage") ~= nil and game.StarterGui:FindFirstChild("DeathMessage") ~= nil then
            if player.Character:FindFirstChild("Humanoid") ~= nil then
                local hum = player.Character:FindFirstChild("Humanoid")
                hum.Died:Connect(function()
                    local DeathMessage = DeathMessages[math.random(1,#DeathMessages)]
                    local Users = game.Players:GetPlayers()
                    for i, User in pairs(Users) do
                        if game.ReplicatedStorage:FindFirstChild("SendDeathMessage") ~= nil then
                            game.ReplicatedStorage.SendDeathMessage:InvokeClient(User, player.Name .. " " .. DeathMessage)
                        end
                    end
                end)
            end 
        end
    end)
end)
I assume you have a similar LocalScript inside for your textlabel where the message will show up:
Code:
local remote = game.ReplicatedStorage:WaitForChild("SendDeathMessage")

local function getmsg(msg)
    script.Parent.Visible = true -- the textlabel
    script.Parent.Text = msg
end


remote.OnClientInvoke = getmsg
 

·
Registered
Joined
·
186 Posts
Discussion Starter · #3 ·
Code:
--Messages
local DeathMessages = {
    "got owned by a rake",
    "tried befriending a rake but died",
    "got ganged up on by some rakes",
    "got uno reverse carded by a rake",
    "got uno reverse carded by a rake",
    "raged too hard",
    "got sent to brazil by a rake",
    "gave up the ghost",
    "got ended by a rake",
    "got set to nil",
    "LOSE, RAKE WIN",
    "got roasted by a rake"
   
   
}

--Actual script
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        if script:FindFirstChild("SendDeathMessage") ~= nil and script:FindFirstChild("DeathMessage") ~= nil then
            script:FindFirstChild("SendDeathMessage").Parent = game.ReplicatedStorage
            script:FindFirstChild("DeathMessage").Parent = game.StarterGui
            if player.Character:FindFirstChild("Humanoid") ~= nil then
                local hum = player.Character:FindFirstChild("Humanoid")
                hum.Died:Connect(function()
                    local DeathMessage = DeathMessages[math.random(1,#DeathMessages)]
                    local Users = game.Players:GetPlayers()
                    for i, User in pairs(Users) do
                        if game.ReplicatedStorage:FindFirstChild("SendDeathMessage") ~= nil then
                            game.ReplicatedStorage.SendDeathMessage:InvokeClient(User, player.Name .. " " .. DeathMessage)
                        end
                    end
                end)
            end
        elseif game.ReplicatedStorage:FindFirstChild("SendDeathMessage") ~= nil and game.StarterGui:FindFirstChild("DeathMessage") ~= nil then
            if player.Character:FindFirstChild("Humanoid") ~= nil then
                local hum = player.Character:FindFirstChild("Humanoid")
                hum.Died:Connect(function()
                    local DeathMessage = DeathMessages[math.random(1,#DeathMessages)]
                    local Users = game.Players:GetPlayers()
                    for i, User in pairs(Users) do
                        if game.ReplicatedStorage:FindFirstChild("SendDeathMessage") ~= nil then
                            game.ReplicatedStorage.SendDeathMessage:InvokeClient(User, player.Name .. " " .. DeathMessage)
                        end
                    end
                end)
            end
        end
    end)
end)
I assume you have a similar LocalScript inside for your textlabel where the message will show up:
Code:
local remote = game.ReplicatedStorage:WaitForChild("SendDeathMessage")

local function getmsg(msg)
    script.Parent.Visible = true -- the textlabel
    script.Parent.Text = msg
end


remote.OnClientInvoke = getmsg
OMG THANK YOU SO MUCH!! I tested it and it works! an award should go to you for knowing this much code! you are the best!
 
1 - 3 of 3 Posts
Top