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

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

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

2 comments

0

Where is your script located? Is it Server or Client/Script or LocalScript

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

1 answer

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

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