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:

01local players = game:GetService("Players")
02local ServerStorage = game:GetService("ServerStorage")
03 
04players.PlayerAdded:Connect(function(plr)
05 
06    print("g")
07 
08    local money = plr.leaderstats:WaitForChild("Money")
09 
10    plr.CharacterAdded:Wait()
11 
12    if script.Parent.Parent == game.Workspace then
13 
14        print("e")
15 
View all 21 lines...

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