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

Removing forcefield with gui button but it doesnt work, what is missing?

Asked by 2 years ago

Hi, I need some help with my script I am still a beginner

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Visible = false 
    script.Parent:FindFirstChild("ForceField"):Destroy()
end)

I know somethings missing but I don't know what is it

and my button is

Button > ScreenGui > Starter Gui

I also tried doing

script.Parent.Parent.Parent:FindFirstChild

too but it doesn't work

0
Where is your script located? Is it Server or Client/Script or LocalScript MattVSNNL 620 — 2y
0
Oh I already figured it out, I used LocalScript since it is a gui but I managed to script it correctly but thanks for trying to help OBEYTHEHOBO 5 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

I already figured it out

player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Visible = false 
    player.Character:FindFirstChild("ForceField")
    player.Character.ForceField:remove()
end)

I should've used player.Character instead of script.Parent

Ad

Answer this question