Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how would i add a bool value checking to see if its on the player?

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)


3 comments

0

and like if its on the player = true then :destroy()

0

so basically you are saying that once when you have clicked you want that attached and second time when clicked you want it to destroy?

0

yes

1 answer

✓ Accepted answer

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!!

4 comments

0

the change going to the replicated storage part worked

0

but how do i make it come back to workspace if i press it again? would i have to loop the script for inv.

0

inf*

0

wait nvm i missed some parts sorry

This discussion is preserved as it was. New answers, comments, and votes are closed.