Ok, so i made a button gui when you would press it a model would attach on the player now i want the script to delete the item when the button gui is pressed again I really don't know what to do.
button = script.Parent.TextButton local vc = game.ReplicatedStorage["Rig BP"] local plr = script.Parent.Parent.Parent local char = plr.character or plr.CharacterAdded:Wait() button.MouseButton1Down:Connect(function() local Clonedvc = vc:Clone() Clonedvc.Parent = char Clonedvc:SetPrimaryPartCFrame(char:WaitForChild("UpperTorso").CFrame) Clonedvc:SetPrimaryPartCFrame(Clonedvc:GetPrimaryPartCFrame() * CFrame.new(0,-.84,.02) * CFrame.Angles(6.28,3.14,0)) local Weld = Instance.new("WeldConstraint") Weld.Part0 = Clonedvc.Main Weld.Part1 = char:WaitForChild("UpperTorso") Weld.Parent = char:WaitForChild("UpperTorso") end)
See i think you just need to understand on how to go about it and then you can implement it on your script yourself.
for example: Consider this script:-
local part = game.Workspace.Part local Detec = part.ClickDetector local ch = game.Workspace.Change local attached = true Detec.MouseClick:Connect(function() if attached == true then attached = false ch.Parent = game.ReplicatedStorage elseif attached == false then attached = true ch.Parent = game.Workspace end end)
here we are making a variable which turns to false when the thing is attached (just consider it for your understanding as attached however its not in my script) when i click the button and also turns true if it was false.
Hope this might help you!!