I’m trying to create a system that when someone kills another player, it makes a system message somewhat like
Killer has killed Player
EDIT: Another issue was found. Original issue can be found below.
Old issue
Now I’ve found an issue here.
I’m trying to create a system that when someone kills another player, it makes a system message somewhat like
Killer has killed Player
EDIT: Another issue was found. Original issue can be found below.
Now I’ve found an issue here.
Wait, if you’re trying to make a system message then why are you trying to do it on the client? Unless if that’s what you wanna do
My god, I completely forgot to fix that! Thank you, will get back if it works or if it does not.
UPDATE: it did not work. The error says OnServerEvent can only be used on the server.
Do FireAllClients()
and have them update their gui there. Unless you don’t want all players to see it. I assume this is a killfeed type thing.
What you can do instead, is put Script 1
as this I think:
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
local Killer = character.Humanoid:findFirstChild("creator")
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = player.Name.." Was killed by "..Killer.."!";
Font = Enum.Font.Cartoon;
Color = TextColor;
FontSize = Enum.FontSize.Size24;
})
end)
end)
end)
You could try this?
It worked! Thanks for the help!
I found another issue. So I put as a placeholder for the text “If you see this it worked”. However when I changed it to the real death message, it stopped working.
Script 1:
local ReplicatedStorage = game.ReplicatedStorage
local DeathEvent = ReplicatedStorage.Death
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
local Killer = character.Humanoid:findFirstChild("creator")
DeathEvent:FireAllClients(player, Killer)
end)
end)
end)
Script 2:
local ReplicatedStorage = game.ReplicatedStorage
local DeathEvent = ReplicatedStorage.Death
TextColor = Color3.new(1, 1, 1)
local function DeathMessage(player, Killer)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = player.Name.." has been killed by "..Killer.."!";
Font = Enum.Font.Cartoon;
Color = TextColor;
FontSize = Enum.FontSize.Size24;
})
end
DeathEvent.OnClientEvent:Connect(DeathMessage)
Probably because of this:
You only specified an object Instance I believe, when I think you should be doing a tostring
function instead? Try this:
local ReplicatedStorage = game.ReplicatedStorage
local DeathEvent = ReplicatedStorage.Death
TextColor = Color3.new(1, 1, 1)
local function DeathMessage(player, Killer)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = player.Name.." has been killed by "..tostring(Killer.Value).."!";
Font = Enum.Font.Cartoon;
Color = TextColor;
FontSize = Enum.FontSize.Size24;
})
end
DeathEvent.OnClientEvent:Connect(DeathMessage)
THANK YOU SO MUCH! It works FLAWLESSLY!