I did the script for a key that is sitting on a dresser to be picked up but when i run it the dresser the key is sitting on and the roof of the house falls apart. Please help me.
Here the script i used:
local tools = {["Wrench"] = true, ["Key"] = true} local radius = 10 local removeToolUponPickUp = true -- true and the tool is removed when picked up, false and it stays local player = game.Players.LocalPlayer local mouse = player:GetMouse() local running = false local found, hint function getTools() local found = {} for _, c in pairs(game.Workspace:GetChildren()) do if tools[c.Name] then table.insert(found, c) end end return found end
function walking(speed) running = speed > 0 and true or false while running and not found do for _, tool in pairs(getTools()) do local pos = tool:GetModelCFrame().p if player:DistanceFromCharacter(pos) < radius then found = true hint = Instance.new("Hint", player.Character) hint.Text = "Press E to pick up "..tool.Name found = tool while true do if player:DistanceFromCharacter(pos) > radius then hint:Destroy() found = nil break end wait(0.25) end end end wait(0.25) end end
mouse.KeyDown:connect(function(key) if key:lower() == "e" and found then local tool = game.Lighting.Tools[found.Name]:Clone() tool.Parent = player.Backpack if removeToolUponPickUp then found:Destroy() if hint then hint:Destroy() found = nil end end end end)
repeat wait() until player.Character wait(0.5) player.Character.Humanoid.Running:connect(walking)
I do not know what else to do.
https://www.roblox.com/library/1864709663/Object-Weld
Add this item to inventory, and in studio drag it under the model that you want to be welded together.
Make sure to select your model and in properties choose the primary part, or else you cannot weld it.