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

My Remote Event Fire Script isn't working, help?

Asked by 5 years ago

So I have a script that fires a client event, a sell event, but it seems to not work.

script.Parent.Touched:connect(function(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
workspace.Events.SandSell:FireClient(player)
end)

Also the formatting is correct in the script itself, just got transferred weirdly. The output is: 17:07:21.572 - FireClient: player argument must be a Player object

1 answer

Log in to vote
1
Answered by
CjayPlyz 643 Moderation Voter
5 years ago
local RemoteEvent = workspace.Events.SandSell

local function Touched (Part)
    local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
    if Player then
        RemoteEvent:FireClient(Player)
    end
end

script.Parent.Touched:Connect(Touched)

You have to make sure that the object that touches the part is a character.

Ad

Answer this question