So when the build tool is equipped, this should allow them to build. When not equipped, they should not be able to build.
Tool called Buildtool with this LOCAL script inside.
local Mouse = game.Players.LocalPlayer:GetMouse() local tool = script.Parent local Equipped = false tool.Equipped:Connect(function() Equipped = true local player = game.Players.LocalPlayer local mouse = player:GetMouse() local val mouse.Button1Down:connect(function() if mouse.Target and mouse.Target.Name ~= "Baseplate" then local block = Instance.new("Part", workspace) -- new Block block.Anchored = true block.Size = Vector3.new(5,5,5) -- block size block.BrickColor = BrickColor.White() block.Name = "TempBlock" end end) mouse.Button1Up:connect(function() if mouse.Target and mouse.Target.Name ~= "Baseplate" then local foundBlock = workspace:FindFirstChild("TempBlock") foundBlock.CFrame = CFrame.new(mouse.Target.Position) + Vector3.new(0,5,0) foundBlock.Name = "PlacedBlock" end end) mouse.KeyUp:connect(function(k) local key = k:lower() if key == "r" then if mouse.Target.Name == "PlacedBlock" then mouse.Target:Destroy() end end end) end) tool.Unequipped:connect(function() Equipped = false end)
Inside each of the input event be sure to run a check to make sure that Equipped
is true. It seems you set up that variable properly, just never used it anywhere.
Ex:
mouse.Button1Down:Connect(function() if Equipped == true then --rest of your code end end)
Also aside from your question, you should try to rework this script to use UserInputService
instead, because events like Mouse.KeyUp
are deprecated.