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

Radius script works in studio but not in a server. Can someone help me?

I have a script that when you walk into the zombies radius it shows his health (health is in another script) but the radius script works when i'm in studio but not in a server, please help D:

local Player = game.Players.LocalPlayer.Character
local Zombie = game.Workspace.Zombie

while wait() do
    if (Player.Torso.Position - Zombie.Torso.Position).magnitude <= 30 then
        script.Parent.BOSS.Frame.Visible = true
	else script.Parent.BOSS.Frame.Visible = false
	end
end

1 answer

This happens because you don't wait for the character to be added.

On line 1, do

local Player = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()

Now, the script will wait until a character is added, or continue if its already there.

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