#how do i make PlayerAdded event loop on a character respawning after reset?
32 messages · Page 1 of 1 (latest)
Mm let me see
use an event to check if CharacterAdded fired
which will fire every time the player gets a new character e.g. after he respawns
My bad
I'm ignoring the fact that he isn't using task.wait()
Oh
oh wait hang on
I didn't actually read the character, no connect it to a function
then it will actually fire multiple times, and actually takes the stack back to that line
now it just yields the stack
if you connect the event to a function then it will play said function every time the event fires
but event:Wait() yields a stack until the event is fired, so if the event fires again then the stack won't move back
ohh so would i change the first line to
player.PlayerAdded:Connect(function(player, CatSwap)
``` ?
Wait what?
are you saying to put the PlayerAdded event into my CatSwap function like this? bit confused but here is the whole thing i adjusted some things
local rs = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local Catcolors = rs.catcolors
local function CatSwap(player)
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
wait(0.5)
local originalcolors = player.Character:FindFirstChildWhichIsA("BodyColors")
local originalshirt = player.Character:FindFirstChildWhichIsA("Shirt")
local originalpants = player.Character:FindFirstChildWhichIsA("Pants")
local originalface = player.Character:FindFirstChild("Head")
wait(0.5)
-- bodycolors
originalcolors:Destroy()
local newcolors = Catcolors:Clone()
newcolors.Parent = player.Character
wait(0.5)
--shirt & pants
originalshirt.ShirtTemplate = 0
originalpants.PantsTemplate = 0
wait(0.5)
-- face
originalface.face.Texture = "http://www.roblox.com/asset/?id=15431991"
end)
end
players.PlayerAdded:Connect(function(player)
wait(0.1)
CatSwap(player)
end)
this code is emmm... interesting
its not too deep its just replacing some things on the character
so PlayerAdded > function > PlayerAdded
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
--all the code code inside CatSwap except for the first 2 lines
end)
end
why do you not just have it like that?
it doesnt do anything for me
also i had catswap as a local function bc i was told functions are supposed to pack lines of code into one string
oooh wait it works now
i had to delete the first 3 lines not the first 2
with first 2 lines I meant
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
which are the first lines of the function
anyways, is it solved now @eager moat ?
yea yea i got it working now tyty