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

I used an event, PlayerAdded, to detect when a player joins the game, but it won't work. Why?

Asked by
Lazarix9 245 Moderation Voter
5 years ago

I've got this script inside of the part:

local players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

players.PlayerAdded:Connect(function(plr)

    print("g")

    local money = plr.leaderstats:WaitForChild("Money")

    plr.CharacterAdded:Wait()

    if script.Parent.Parent == game.Workspace then

        print("e")

        money.Value = money.Value + 75

        wait(7)

    end
end)

So what it does basically - the part is in ServerStorage and when player logs in if they have gamepass part is in workspace so if its in workspace i want to give money every 7 seconds but it doesnt work.

also when player joins "g" doesnt get printed so yeah

I thought it's maybe because scripts dont work in ServerStorage perhaps, but idk, pls help

1 answer

Log in to vote
1
Answered by
metryy 306 Moderation Voter
5 years ago

Scripts don't run in ServerStorage. You need to put the script in ServerScriptService or the workspace for it to run.

0
Thank you, that worked ^^ Lazarix9 245 — 5y
Ad

Answer this question