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

This Script wont Work on The Published Game But works On Studios ?

Asked by 6 years ago

the script woks On studio But it wont Work On The published game

repeat wait() until game.Players.LocalPlayer 
and game.Players.LocalPlayer.Character

local player = game.Players.LocalPlayer
char = player.Character
hum = char.Humanoid

button = script.Parent
count = script.Parent.Parent:WaitForChild("CostHC")
HC = script.Parent.Parent:WaitForChild("HealthC")
price = 75 
UP = false
max = 200



button.MouseButton1Click:connect(function()
    local hum = char.Humanoid
if hum.MaxHealth == max then

elseif player.leaderstats.Money.Value <= price then

    elseif UP == false then
    hum.MaxHealth = hum.MaxHealth + 1
    player.leaderstats.Money.Value = player.leaderstats.Money.Value - price
    price = price + 25
count.Text = price
HC.Text = HC.Text + 1
    end
end)

at firs i Was getting an error saying Player attempted to index(nil value) i think that was the error it gave me, bu now i get no output plz he thx :)

0
is this in a regular script PyccknnXakep 1225 — 6y
0
If it is a regular script, then read my bio. hiimgoodpack 2009 — 6y
0
ok it Was FilthyMonsterPlays 8 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

A error saying the player is a nil value is most likely to indicate that you're using a server script, when you should be using a local script instead since only a local script can access the LocalPlayer via the Players service.

Ad

Answer this question