EDIT: This script is supposed to spawn a tent near the player, also, it is an hopperbin tool.
tent = game.Lighting.Tent1
work = true
close = false
d = nil
function onButton1Down(mouse)
player = script.Parent.Parent.Parent.Character
ft = player:findFirstChild("Tent")
if ft ~= nil then
print("Tent Already Pitched")
return
end
if work == false then return end
work = false
wait(2)
work = true
newtent = tent:clone()
newtent.Name = "Tent"
c = newtent:GetChildren()
newtent.Parent = player
print("Player Found")
local t = player:findFirstChild("Torso")
if t ~= nil then
print("Torso Found")
p = newtent
d = p.Door
p:MoveTo(t.Position + Vector3.new(0, -5, -13))
p:MakeJoints()
print("Tent Pitched")
p.Bed.Color = Color3.new(math.random(), math.random(), math.random())
for i, v in pairs(c) do
if c[i].className == "Part" then
c[i].Color = p.Bed.Color
end
end
p.NameTag.Name = player.Name.."'s tent."
wait(0.5)
p.Bed.BrickColor = BrickColor.new(1)
end
end
function onKeyDown(key)
if (key~=nil) then
key = key:lower()
if (key=="t") then
local t = script.Parent.Parent.Parent.Character:findFirstChild("Tent")
if t ~= nil then
t:remove()
end
end
if (key=="c") then
if close == false then
d.Transparency = 0
d.CanCollide = true
close = true
elseif close == true then
d.Transparency = 1
d.CanCollide = false
close = false
end
end
end
end

2 comments
Is this a Script or a LocalScript? Can you explain the hierarchy of objects this is part of?
It's an hopperbin that is supposed to spawn a tent, and it's just a script.