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

2 Events not firing in a local script?

-- Local script

local ToolName = "TestTool"
local rs  = game:GetService("ReplicatedStorage")
local backpackRemote = rs.Remotes:WaitForChild("playerBackpack")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		while wait() do
			local tools = player.Backpack:GetChildren()
			local backpack = player.Backpack
			if 1 == 1 then
				warn(backpackRemote.."Fired")
				backpackRemote:FireServer(char,tools,backpack)
			end
		end
			
	end)

end)

1 comment

0

This shouldn't be a server script. Use LocalPlayer instead of PlayerAdded.

1 answer

✓ Accepted answer

You can't use FireServer() inside a local script. I recommend reading this as it'll help you understand what i'm talking about better.

-- Local script

local ToolName = "TestTool"
local rs  = game:GetService("ReplicatedStorage")
local backpackRemote = rs.Remotes:WaitForChild("playerBackpack")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        while wait() do
            local tools = player.Backpack:GetChildren()
            local backpack = player.Backpack
            if 1 == 1 then
                warn(backpackRemote.."Fired")
                backpackRemote:FireClient(player,char,tools,backpack)
            end
        end

    end)

end)

I replaced FireServer() with FireClient() and put player inside the parameters which will let the script know the player that the remove event is being fired to. I hope this helps.

5 comments

0

Please accept my answer if this worked :).

0

oh yeah

0

i did a mistake i got mixed up between server and client lol

0

nvm i was wrong

0

fixed it but i will accept answer anyways

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