local button = script.Parent
local gui = script.Parent.Parent.Parent:WaitForChild("BuildingGui")
local rS = game:GetService("ReplicatedStorage")
local char = game:GetService("Players").LocalPlayer.Character
local debounce = false
button.MouseButton1Up:Connect(function()
if not debounce then
debounce = true
if not gui.Enabled then
--- if gui is closed, create the tool and weld it to the character's hadn
gui.Enabled = not gui.Enabled
local pda = rS.Items:WaitForChild("PDA"):Clone()
pda.Parent = char
local weld = Instance.new("WeldConstraint")
weld.Parent = char:FindFirstChild("LeftHand")
weld.Part0 = char:FindFirstChild("LeftHand")
local pda = rS.Items:WaitForChild("PDA"):Clone()
weld.Part1 = pda.Handle
pda.Parent = char
pda:SetPrimaryPartCFrame(char.LeftHand.CFrame)
print(pda.PrimaryPart.CFrame)
print(char.LeftHand.CFrame)
wait(0.5)
debounce = false
else
--- if the gui is already open, destroy the tool and weld
gui.Enabled = false
local pda = char:FindFirstChild("PDA")
if pda then
pda:Destroy()
end
local weld = char.LeftHand:FindFirstChild("WeldConstraint")
if weld then
weld:Destroy()
end
end
end
end)
Whenever I try to create the tool, it immediately flings itself, despite both cancolllide and anchored being turned off.