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

hello! can you find whats wrong with my script? its a thing that kinda happens for some reason idk.

Asked by
kuru226 13
2 years ago
while true do
    wait(.5)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
    character = player.CharacterAdded:wait()
end

if character.Humanoid.Health == 90 then
    script.Parent.Transparency = 0.9
    end



end

so thats the coodee, im trying to make a thing to become more transparent when the player's health gets over to 90. its showing an error on line 5 ("local character = player.Character ") the error just shows " attempt to index nil with 'Character' "

0
This is a server script, if you want this part to become invisible only for the player who has 90 health than you should make this a LocalScript and put inside of StarterCharacterScripts imKirda 4491 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

This is a script, and so it cannot get the LocalPlayer through game.Players.LocalPlayer or through the service. Make this a LocalScript, and you can get the LocalPlayer that way.

Ad

Answer this question