Hello DevFourm, I’ve recently been working on an obby in my game to keep players entertained. I’ve made a chest at the end of every obby to award them once they complete it.
There is a green glowing part on the ground in front of the chest that the players have to touch in order to get the award.
For this, I have a remote event that fires the player’s Display name and the amount to award them. (Since their data is saved in a DataStore)
However, when I touch the part, “Unable to cast value to object” appears…

I haven’t spotted any errors to my knowledge. Here’s the script:
-- Veriables
local part = script.Parent
local event = game.ReplicatedStorage.PartTouched
local db = false
-- Script
function addMarbles(hit)
local humnaoid = hit.Parent:FindFirstChild("Humanoid")
if db == true then
return
else
if humnaoid then
db = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
print("part touched")
if player then
event:FireClient(player.DisplayName, 2)
task.wait(1.5)
db = false
end
else
return
end
end
end
-- Function Calls
part.Touched:Connect(addMarbles)
(This script is inside the green glowing part the player touches)
Thank you, anything helps ![]()