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

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

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

✓ Accepted answer

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

1 comment

0

Thank you, that worked ^^

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