Hello, I would like to have the name of the model and put it in the fireclient but it tells me the error “Unable to cast value to object” do you have any solutions?
local proximityPrompt = script.Parent.ProximityPrompt
local event = game.ReplicatedStorage:WaitForChild("Turnstile")
local function onTrigger(player)
event:FireClient(script.Parent.Parent.Parent.Name)
end
proximityPrompt.Triggered:Connect(onTrigger)
This is a common mistake. The reason this is happening is because you’re trying to fire to a string, or at least that’s what the script thinks. Your first argument should be the Player that you’re firing to, then the other arguments for whatever else. So, it would look like this:
remote:FireClient(player, otherArgument)
“Unable to cast value to object” occurs when you try to pass an invalid argument type. For example, in this case you tried to cast a string instead of a Player.