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

Unable to cast value to Object?

Trying to fire a value from the server to the client (it's just basic info no worrying to be done with the client getting control)

				local cashtogive = game.ServerStorage.ToolModels[player.Equipped.Value].Stats.MoneyStat.Value --OOF ITS COMPLICATED!
				print(game.ServerStorage.ToolModels[game.Players[player.Name].Equipped.Value].Stats.MoneyStat.Value)
				game.ReplicatedStorage.AnimationRemotes.SellAnimation:FireClient(cashtogive)

It prints properly, however it then doesn't fire to a local script and instead errors with "Unable to cast value to object"

2 comments

0

also sorry about weird script formatting

0

my brain

1 answer

✓ Accepted answer

The issue is line 3:

game.ReplicatedStorage.AnimationRemotes.SellAnimation:FireClient(cashtogive)

You're trying to fire a remote event to a number! FireClient first argument is the player to fire to, always. Or else the server won't know which player to fire to. Judging from line 1, you already have the player, so just change the line to

game.ReplicatedStorage.AnimationRemotes.SellAnimation:FireClient(player, cashtogive)

And if your OnClientEvent listener has the player as an argument, remove it.


######Hopefully this answered your question, and if it did, then don't forget to hit that "Accept Answer" button, and optionally, give an upvote. It helps out a lot. If you have any other questions, then feel free to leave them down in the comments.

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