I am just trying to make a really simple spawn point that activates when the player claims a tycoon in my tycoon game. For some reason plr.CharacterAdded is not firing at all! along with CharacterAppearanceLoaded and CharacterRemoving.
Also the bindable event that triggers when the player claims the tycoon is only being received like half the time, and I have no idea why since I know it is being fired. The way I made sure it was being fired correctly was making a separate script that just waiting for it to be fired and then prints something. It printed it every time successfully.
I’ve been using studio and scripting for almost year, and i’ve never experienced this before. I feel like im going crazy lol
In this case, if its specifically the CharacterAdded event not firing, it may be because the character is already loaded.
Maybe this will work
local ownerEvent = script.Parent.Parent.TycoonClaimer.OwnerAdded
ownerEvent.Event:Connect(function(plr)
if plr.Character then
plr.Character:WaitForChild("HumanoidRootPart").CFrame = script.Parent.CFrame
end
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("HumanoidRootPart").CFrame = script.Parent.CFrame
end)
end)
CharacterAdded fires when the character is first spawned, so after you reset or first join the game. If the player can walk around and has to manually claim a spot then the character already exists and you don’t need the function
That didnt work sadly. I mean it’s doing the same thing im already doing basically, just adding an extra step of teleporting the player right when they claim the tycoon which is not needed,
@jetape what im trying to make is a spawn point for when you die in the future you will spawn at your tycoon instead of the global spawn point. So i want to connect CharacterAdded to teleporting the player to the tycoon.
It seems like this could be a studio bug, since this really makes no sense, and I havent found anything online about it either. Im gonne try to upload the game is test it in actual roblox.
edit: still didnt work. I am so very confused
add some print statements to know where exactly the issue in the script
try using this code and say if any of the print statements didn’t print or if you got any errors
script.Parent.Parent.TycoonClaimer.OwnerAdded.Event:Connect(function(plr)
print(`Event Fired {plr}`)
plr.CharacterAdded:Connect(function(char)
print(`{char} is Added`)
char:WaitForChild("HumanoidRootPart").CFrame = script.Parent.CFrame
print(`Character CFrame is set to {script.Parent.CFrame}`)
end)
end)
Event fired prints every time (which is weird because I swear when I tested this before it wasnt firing) but character is added never prints. So for some reason the CharacterAdded event wont fire at all
Use the on character added function first, then check if they claimed the tycoon, and teleport them accordingly. Hopefully this was helpful! (I’m on mobile so it would be hard to write or test code)
local pos:CFrame = script.Parent.CFrame
script.Parent.Parent.TycoonClaimer.OwnerAdded.Event:Connect(function(plr:Player):()
warn(plr,"Added")
plr.CharacterAdded:Connect(function(char:Model):()
local root = char:WaitForChild(“HumanoidRootPart”,10)::Part?
print(root)
if root==nil then return end
root.CFrame = pos
end)
end)
Set player.RespawnLocation = to a spawnlocation instance
script.Parent.Parent.TycoonClaimer.OwnerAdded.Event:Connect(function(plr)
plr.RespawnLocation = script.Parent -- Instead of using a CFrame value use a spawnlocation
end)
Still don’t know why CharacterAdded won’t fire but fixes the problem for now. And @i_playingthisgame90’s solution would probably work, haven’t tested it yet tho. Thanks to all for helping!
Of course, happy to help! I believe the reason character added wasn’t working correctly could be that character added doesn’t fire on client sided scripts.