Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Using FireAllClients for Killfeed?

Asked by 2 years ago

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)
0
If your using FireAllClients you don't need to pass the player argument. Babyseal1015 56 — 2y

1 answer

Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

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
Ad

Answer this question