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

How do you make this incinerator script that destroy boxes right ?

Asked by 4 years ago

I'm making a incinerator where if you hold a a specific tool (BOX) it will destroy it but for some reason this script doesn't mark anything , the output doesn't say anything please help ?

local box = game.Workspace.BOX
local thing = script.Parent
local player = game.Players.LocalPlayer
thing.Touched:Connect(function()
    if player.Backpack:FindFirstChild("BOX") then
       box:Destroy()
        print("Removed the players Item")
    else if player.Backpack.Box ==false then
          player.Backpack.BOX = false
      end
    end
end)

PS this is a local script BTW

0
What is the variable at the top? jensar141215 157 — 4y
0
The tool Redyblazeyy 31 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Use a serverscript instead of a localscript. The issue here is you trying to define player using something that would only work inside a player. Put this script inside of a part.

local thing = script.Parent
thing.Touched:Connect(function(Touch)
     local Player = Touch.Parent
print(Player)
if Player:FindFirstChild("Box") ~= nil then
    Player:FindFirstChild("Box"):Destroy()
        print("Removed the players Item")
      end
end)
Ad

Answer this question