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

Why wont this work? heres the error: 14:45:37.579 - RebirthCost is not a valid member of Player

Asked by 4 years ago
Edited 4 years ago

This function is not working, im trying to make text update instantly but it cant find the player. Also if i run the game, look in the players part of the explorer and find my user name and open that up there is a value that is called RebirthCost that is attached to the player

game.Players.LocalPlayer.RebirthCost.Changed:Connect(function()
    script.Parent.Cost_Multiplier.Text = "Cost: $" .. game.Players.LocalPlayer.Cost.Value .. ", Multiplier: x" .. game.Players.LocalPlayer.Rebirths.Value + 1 * 2
end)

2 answers

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

create the var in a regular script

game.Players.PlayerAdded:Connect(function(plr)
    local Value = Instance.new("IntValue")
    Value.Name = "RebirthCost"
    Value.Parent = plr.Character
    Value.Value = 100
end)
Ad
Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago

We found the answer in the chat, he had to use WaitForChild in case it hasn't loaded yet

Answer this question