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

Script never runs?

Asked by
Mowblow 117
9 years ago

The following code is inserted into the player when they join, it is copied from the serverstorage, however the code never runs!

Here is the code:

local player = script.Parent
local playerfolder = game.Workspace:FindFirstChild(player.."Time")
local playertime = playerfolder:FindFirstChild("PlayerElapsedTime")
local playertimevalue = playertime.Value


while true do
    playetimevalue = playertimevalue + 1
    print("Value Updated")
    wait(1)

end

The code is extremely simple, but doesn't run the loop when it is placed into the player.

Any suggestions?

0
Try putting it in StarterPlayer.StarterPlayerScripts and see if it does anything then. adark 5487 — 9y
0
Disable the script inside ServerStorage, and when the time comes for the player to obtain it, enable the script there while it is being given to player. Marios2 360 — 9y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

I think I've spotted your problem. On line 4, you added .Value. To be honest, I don't know the exact reason for this, but I believe you should remove the .Value from defining the variable. You would put .Value on line 8. So..

local player = script.Parent
local playerfolder = game.Workspace:FindFirstChild(player.."Time")
local playertime = playerfolder:FindFirstChild("PlayerElapsedTime")


while true do
    playertime.Value = playertime.Value + 1
    print("Value Updated")
    wait(1)
end

Ad

Answer this question