|
| 03 Jan 2016 07:04 PM |
I tried to make a Stamina bar , it perfectly work in Solo there are no error at all.When I try it on local Server , there are 2 major errors.
1st: The Stats Folder isn't created by the ServerScriptService and since it isn't created the Stamina IntValue isn't created as well.
2nd:Since these two doesn't exist , the really basic script , doesn't work and sprinting doesn't work anymore.
That's just the script to load the value , when the player joins the game: game.Players.PlayerAdded:connect(function(player) player = game.Players.LocalPlayer local Stats = Instance.new("Folder") Stats.Parent = player Stats.Name = "Stats" local Stamina = Instance.new("IntValue") Stamina.Parent = Stats Stamina.Name = "Stamina" Stamina.Value = 100 end)
The Output error state: 20:02:52.844 - Stats is not a valid member of Player 20:02:52.844 - Script 'Players.Player2.PlayerGui.StatsGui.Box.StamBar.LocalScript', Line 4 20:02:52.845 - Stack End
I'm not sure if it is because the value hasn't loaded , because when I go check the folder , they aren't even there , so I wasn't sure if it was the ServerScriptService who had an error or the Stamina Bar. I tried the player:waitForCharacter() and it didn't worked as well.
Thanks for helping me out , I'm still a beginner. |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 07:05 PM |
>Can't access local player through a server script.
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 07:07 PM |
| So how do I make it? I tried to make a local script , but since they can't be put in ServerScript it haven't work either. What should I do? |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 07:08 PM |
You've already got the player in the playeradded event:
game.Players.PlayerAdded:connect(function(player) if player then end end)
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 07:10 PM |
^you dont need "if player then"
|
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Jan 2016 07:14 PM |
| Thanks for the help, it work right now. Wow this error was so freaking foolish , I was so blind. Maybe that the error that broke my other STR game x_x |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 07:25 PM |
^ if player and player:IsA('Player') then Gotta make sure it isnt a supercomputer.
[Work not tested, not bested.] |
|
|
| Report Abuse |
|
|