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
Well, most of the time if it will work in Studio and not in a server is because of Filtering Enabled. If you have Filtering Enabled then the client can not create or change anything held on the server, so it would only be on the client. But let's say we want the client to change something specific on the server, you would do this with RemoteFucntion and RemoteEvnent. Now, that could be one of the problems but there's no guarantee.
Here's some other pointers while I'm here: 1.)Don't store stuff in lighting, use ServerStorage or ReplicatedStorage. 2.)If you're going to delete a object, don't use :remove(), use :Destroy. Removing stuff with :remove() does not actually delete them. It just sticks them into the server's memory for later which can slowly slow the server down. It's like putting stuff into the recycle bin on your desktop. Instead, using :Destroy() actually deletes the object.