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

Where should I place a server script that functions on Join?

Here's my script;

local Players = game:GetService("Players")


local function onPlayerAdded(player)
	local ability = player:WaitForChild("Status"):WaitForChild("Ability")
	if ability.Value == "None" then
		return
	end
	if ability.Value == "Magnet" then
		local Clone = game.ReplicatedStorage:WaitForChild("MagnetPunch"):Clone()
		Clone.Parent = player.Backpack
	end
end

for _,player in pairs(Players:GetPlayers()) do
     onPlayerAdded(player)
end

Players.PlayerAdded:connect(onPlayerAdded)

It won't function so I don't know. There were no errors so I'm guessing I placed it in the wrong place. Where should I place it and if there are any errors please tell me.

2 answers

✓ Accepted answer

Scripts will execute their containing code whenever they are inside Workspace or ServerScriptService.>

  • From the wiki.

However, the problem is not in the placement. The problem is probably that there is no Magnet as value of status... So its just returning false. But if it's not that try printing 2 separate things one at the start of the function and one after the wait line.

1 comment

0

Status is a model inside players containing stats and more

It would probably be put in ServerScriptService or Workspace. I would think that it would be able to be put anywhere, though, as long as its in the server and not in the player.

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