Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script never runs?

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?

2 comments

0

Try putting it in StarterPlayer.StarterPlayerScripts and see if it does anything then.

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.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.