Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Unable to cast value to Object?

Asked by
Donut792 216 Moderation Voter
5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)

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) Donut792 216 — 5y
0
alright will do thanks Donut792 216 — 5y
0
well main problem solved but now the localscripts not printing anything or changing the bool value Donut792 216 — 5y
0
did you set the bool back to false after the command? the8bitdude11 358 — 5y
Ad

Answer this question