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

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

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' "

1 comment

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

1 answer

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.

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