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

Why Wont My FireClient() Script Work, Server To Client?

Asked by
NSMascot 113
4 years ago
Edited 4 years ago
local event = game.ReplicatedStorage.Events["Enter/ExitCaveEvent"]

script.Parent.Touched:Connect(function(player)
    event:FireClient(player)
end)

When it fires server, the output says this

20:06:47.589 - FireClient: player argument must be a Player object

I named everything correct, I don't know why this is happening!!! Can someone help me? Here is the client code

local event = game.ReplicatedStorage.Events["Enter/ExitCaveEvent"]

event.OnClientEvent:Connect(function(player)
        if workspace.CaveStuff.DetectionBrick.ShowEnter == true then
            workspace.CaveStuff.DetectionBrick.Script.Disabled = true
            print("Enter")
            wait(0.5)
        end
        if workspace.CaveStuff.DetectionBrick.ShowEnter == false then
            workspace.CaveStuff.DetectionBrick.Script.Disabled = true
            print("Exit")
        end
    end)



ty NSMascot

2 answers

Log in to vote
0
Answered by 4 years ago

You're firing a part instead of a player. Basically, when the part is touched, it gives the part that touched it, not the player. Since the part that touches it is the child of a character, instead of event:FireClient(player), you've gotta do event:FireClient(game.Players:GetPlayerFromCharacter(player.Parent)). By the way you might want to change the variable name from "player" to something else to avoid confusing yourself

0
-1, u literally restated what i wrote 30 minutes after i said it. EmbeddedHorror 299 — 4y
0
and firing player.Parent might still give an error, based on which part hit. EmbeddedHorror 299 — 4y
0
First of all, you explained what the problem was. I provided a script, you didn't. Second, I have never encountered any problems using .Parent that way. In fact there are no parts in character that have a a parent other than the character. I try to be nice but it sounds to me that you just don't like me giving a better answer because you're worried that mine will be marked instead of yours IceAndNull 142 — 4y
0
I really don't see why I'm being downvoted for providing a correct answer. IceAndNull 142 — 4y
0
thankyou for the answer, i have been stuck on that for ages NSMascot 113 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

touched returns an objectvalue, and fireclient takes a player parameter. U have to specify which player to fire for a fireclient. rn u r firing an object, so roblox is throwing an error

0
thankyou for the answer, i have been stuck on that for ages NSMascot 113 — 4y

Answer this question