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

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

Asked by
Mayk728 855 Moderation Voter
7 years ago
Edited 7 years ago

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?

0
You should be using event not an infinite loop for this task. User#5423 17 — 7y

1 answer

Log in to vote
2
Answered by
farrizbb 465 Moderation Voter
7 years ago

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

0
Oh thanks, it worked! That was such a simple mistake. Mayk728 855 — 7y
Ad

Answer this question