Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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)


0
and like if its on the player = true then :destroy() Fxding_cam 60 — 4y
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? hallmk7 50 — 4y
0
yes Fxding_cam 60 — 4y

1 answer

Log in to vote
1
Answered by
hallmk7 50
4 years ago

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

0
the change going to the replicated storage part worked Fxding_cam 60 — 4y
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. Fxding_cam 60 — 4y
0
inf* Fxding_cam 60 — 4y
0
wait nvm i missed some parts sorry Fxding_cam 60 — 4y
Ad

Answer this question