What do I fix? Box issue

So, I’m trying to make a pad that connects with a box. When it connects like touches together the box is suppose to disappear or something but it doesn’t work. Is there something wrong with the script?

script.Parent.Touched:Connect(function(Hit)
local player = game.Players:GetPlayerFromCharacter(Hit.Parent.Parent)
print(Hit.Parent.Name)
local char = Hit.Parent
if Hit.Name == ‘JobBox’ then
print(‘BOXHIT’)
script.Parent.Parent.Anim.Value = ‘false’
script.Parent.Parent.Taken.Value = ‘false’
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 20
Hit:Destroy()

end

end)

Can you show me the explorer window and objects of the game?

Sure.
Here is another script btw. while(1)do
wait(1)
if script.Parent.Anim.Value == ‘true’ then
wait(10)
–workspace:FindFirstChild(script.Parent.Owner.Value).LeftHand.JobBox:Destroy()
script.Parent.Anim.Value = ‘false’
script.Parent.Taken.Value = ‘false’

end
end

Also here is the box I use.

And here is the truck with the boxes.

Here is the pad btw.

From my assumption, the JobBox is placed inside the Player’s Character, right?
If so then:

local player = game.Players:GetPlayerFromCharacter(Hit.Parent.Parent)

Would need to be changed to:

local player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)

Since Hit.Parent is the character, and Hit.Parent.Parent would be Workspace.
Also, use GetService for getting Services.

Alright, I’ll try it. :grinning: Thanks!

1 Like