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

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

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

✓ Accepted answer

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

5 comments

0

-1, u literally restated what i wrote 30 minutes after i said it.

0

and firing player.Parent might still give an error, based on which part hit.

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

0

I really don't see why I'm being downvoted for providing a correct answer.

0

thankyou for the answer, i have been stuck on that for ages

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

1 comment

0

thankyou for the answer, i have been stuck on that for ages

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