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

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

Asked by
VVired 28
7 years ago

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

Log in to vote
2
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

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.

Ad

Answer this question