If I’m understanding correctly, you want to have a separate variable for the character outside the PlayerAdded event??
That’d just make it so each time a player joins their character overrides the value.
game.Players.PlayerAdded:Connect(function(Player) -- Player joined
Player.CharacterAdded:Connect(function(char) -- Character's player added, includes when the character dies, :LoadCharacter(), and maybe some other stuff idk abt
-- do stuff here
end)
end)
alternatively you can put a script inside StarterCharacterScripts and then do
local char = script.Parent
but this ends up creating more scripts than necessary since there’s one script per player. Overall the server is doing the same amount of work though, so idk it’s your call.
Oh alright, i understand. So im making OverlapParams. And i need to get character to make it. From the server script. Thats why i want character variable.
game.Players.PlayerAdded:Connect(function(Player) -- Player joined
Player.CharacterAdded:Connect(function(char) -- Character's player added, includes when the character dies, :LoadCharacter(), and maybe some other stuff idk abt
-- do stuff here
end)
end)
char inside the CharacterAdded event is your character variable, and if you put the code in there you can use it as you were intending for it to be used.
So if you wanted to print a character’s name each time they respawn you’d do
Code
game.Players.PlayerAdded:Connect(function(Player) -- Player joined
Player.CharacterAdded:Connect(function(char) -- Character's player added, includes when the character dies, :LoadCharacter(), and maybe some other stuff idk abt
print(char.Name)
end)
end)
(wait were you just saying this or were you still asking for something)
Thanks for everything. I just made it. I dont know who is i gonna check as solution. I will write to title. You both deserving it. Your both script works properly. Thanks
Ohhh I see now ok yeah if you need OverlapParams then go with making a list of the characters like @rfailes said.
Though you’ll need to adjust some things, like adding a CharacterRemoving event to remove values from the list when a character… removes… and stuff like that.
Also mark @rfailes as the solution he gave the list solution.