Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Using FireAllClients for Killfeed?

Okay so I'm trying to make a killfeed script but it only appears for the killer. Why is this? Im gonna leave out some of the script that doesn't relate to the killfeed.

SERVER SCRIPT

if e.Health <= 0 then
    if root.Parent.Dead.Value == false then
        root.Parent.Dead.Value = true
	killed = root.Parent
	local killedname = killed.Name
										game.ReplicatedStorage.ShowFeed:FireAllClients(player,killedname)
     end
end

** LOCAL SCRIPT**

game.ReplicatedStorage.ShowFeed.OnClientEvent:Connect(function(player,killedname)
	local c = player.PlayerGui.Killfeed.FeedFrame.Feed:Clone()
	c.Parent = player.PlayerGui.Killfeed.FeedFrame
	local Tween = game:GetService("TweenService"):Create(c,TweenInfo.new(.2),{TextTransparency=0})
	Tween:Play()
	local random = math.random(1,4)
	if random == 1 then
		c.Text = player.Name.." executed "..killedname
	elseif random == 2 then
		c.Text = player.Name.." cut down "..killedname
	elseif random == 3 then
		c.Text = player.Name.." put "..killedname.." to rest"
	elseif random == 4 then
		c.Text = player.Name.." bested "..killedname
	end
	wait(.3)
	local Tween = game:GetService("TweenService"):Create(c,TweenInfo.new(1.5),{TextColor3=Color3.new(0, 0, 0)})
	Tween:Play()
	wait(5)
	local Tween = game:GetService("TweenService"):Create(c,TweenInfo.new(.5),{TextColor3=Color3.new(1, 1, 1)})
	Tween:Play()
	wait(.3)
	local Tween = game:GetService("TweenService"):Create(c,TweenInfo.new(2),{TextTransparency=1})
	Tween:Play()
	wait(1.2)
	c:Destroy()
end)

1 comment

0

If your using FireAllClients you don't need to pass the player argument.

1 answer

What happens is that you are creating variable player on this line:

ShowFeed.OnClientEvent:Connect(function(player,killedname)

This variable will refer to the killer player, on the next line you are trying to access PlayerGui of this variable, however, this variable will always be the killer player, everyone is trying to copy frame from his GUI, however, they can't access it so they should see an error that the GUI is missing, it's local to every player.

What you want to do is copy your FeedFrame, not killer's frame, by your i mean the player who received the event, and that player is called local player, to get him, use Players.LocalPlayer variable:

local c = game.Players.LocalPlayer.PlayerGui.Killfeed.FeedFrame.Feed:Clone()
c.Parent = game.Players.LocalPlayer.PlayerGui.Killfeed.FeedFrame

This discussion is preserved as it was. New answers, comments, and votes are closed.