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

If player has a forcefield then show it on text, but when forcefield is removed i get an error?

I have a script in a Gui that tells the player if they have a forcefield on screen. The problem i have is once the forcefield is removed, i get an error instead of making the text invisible.
Error: ForceField is not a valid member of Model.

local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Character

while true do
	wait(1)
	if player.ForceField then
		script.Parent.Visible = true
		script.Parent.Text = "ForceField"
	else
		script.Parent.Visible = false
	end
end

Any help pls?

1 comment

0

You should be using event not an infinite loop for this task.

1 answer

✓ Accepted answer

I'm not 100% but if player:FindFirstChild("ForceField") then do your script

1 comment

0

Oh thanks, it worked! That was such a simple mistake.

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