Does anyone know why we can't get the name of the model using this method?

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)

Thank.

Here’s information on what parameters can be passed by FireClient.Parameter Limitations for Bindables and Remotes | Roblox Creator Documentation

Also, where is the script located and what type of script is it?

Leagcy script in workspace in a model. why ?

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.

1 Like

Because the type of script (Local or Server) and it’s location can make a difference on how the script functions.

As you can see from mine and @Ovibion’s post there are only certain parameters that can be called by FireClient.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.