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?

im not good with remote events but i do know on :FireClient() the first parameter is always the player but if i leave it blank it says missing or nil and if i define the player it says unable to cast value to object any help?

--script
script.Parent.Touched:Connect(function(hit)
game.ReplicatedStorage.Battery:FireClient(hit.Parent.Name)
end)
--localscript
game.ReplicatedStorage.Battery.OnClientEvent:Connect(function(hit)
	hit.Backpack.Battery.Value = true
	print(hit.Name.."Has Picked Up Battery")
end)

1 answer

✓ Accepted answer

your sending the character's name, not the player!

--script
script.Parent.Touched:Connect(function(hit)
game.ReplicatedStorage.Battery:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
end)

5 comments

0

ty, now im getting this 20:50:24.181 - Remote event invocation queue exhausted for ReplicatedStorage.Battery; did you forget to implement OnClientEvent? (x349)

0

alright will do thanks

0

well main problem solved but now the localscripts not printing anything or changing the bool value

0

did you set the bool back to false after the command?

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