Personal script not working

Hey scripters, I’m trying to make a spell that only works for me but every time I try to put in my user ID it tells me that UserID is not a valid member of RBXScriptSignal. Can someone help me out?

heres my script

local fire = game.Workspace.cave.FirePart.Fire
local light = game.Workspace.cave.FirePart.PointLight
local player = game.Players.PlayerAdded

if player.UserID == 1991747599 then
	game.Players.PlayerAdded:connect(function(player)
		player.Chatted:connect(function(msg)
			if msg == "phasmatos ignalusum" then
				fire.Enabled = true
				light.Enabled = true
				print ("fired") 
				wait(10)
				fire.Enabled = false
				light.Enabled = false
				print ("extinguished")

			end
		end)
	end)
end

This is because game.Players.PlayerAdded is intended to be an event that fires when a player is added to the game. It’s commonly used in functions, rather than variables.

Here’s how to fix:

local fire = game.Workspace.cave.FirePart.Fire
local light = game.Workspace.cave.FirePart.PointLight

game.Players.PlayerAdded:connect(function(player)
	if player.UserID == 1991747599 then
		player.Chatted:connect(function(msg)
			if msg == "phasmatos ignalusum" then
				fire.Enabled = true
				light.Enabled = true
				print ("fired") 
				wait(10)
				fire.Enabled = false
				light.Enabled = false
				print ("extinguished")

			end
		end)
	end
end)

Note: You seem to put game.Players.PlayerAdded twice, which is inefficient, even if one of them don’t work.

1 Like

I didn’t know that PlayerAdded was an event, thank you very much for your help!

1 Like