CoderHusk
(CoderHusk)
March 25, 2021, 8:05pm
#1
Let me get rid of all the meta replies real quick
Yes, it is a server script
Yes, it is in ServerScriptService
Yes, the script isn’t disabled
No, I am not using spawn location
No, the leaderstats are not nil
No, the function does fire
The plr variable is actually the parameter passed from the PlayerAdded event.
Anyways with that out of the way I have this code-snippet
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("HumanoidRootPart").CFrame = workspace.Levels.LevelsPhysical[tostring(plr.leaderstats.Levels.Value)].CFrame + Vector3.new(0,5,0)
end)
Oddly enough when running it in the terminal in-game with
local char = workspace.CoderHusk workspace.Levels.LevelsPhysical[tostring(game.Players.CoderHusk.leaderstats.Levels.Value)].CFrame + Vector3.new(0,5,0)
it works. However the code-snippet I first showed doesn’t work for some odd reason.
A thing I think I should note is that when I respawn my humanoid root part starts really high up and lands not at (0,0.5,0) but rather (0,0,3)
ShyFlooo
(Flo)
March 25, 2021, 8:07pm
#2
Maybe try this
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("HumanoidRootPart").CFrame = workspace.Levels.LevelsPhysical[tostring(plr.leaderstats.Levels.Value)].CFrame + Vector3.new(0,5,0)
end)
end)
1 Like
CoderHusk:
A thing I think I should note is that when I respawn my humanoid root part starts really high up and lands not at (0,0.5,0) but rather (0,0,3)
Could it be possible that you rotated the part by accident?
CoderHusk
(CoderHusk)
March 25, 2021, 8:09pm
#4
My buddy on discord helped me out, oddly enough they don’t say this on the wiki but CharacterAdded fires when the player just “exists” the parent was nil. I fixed it by just waiting till it was in workspace
1 Like
Hello, how are you doing?
If i’m right, CFrames cannot have strings.
You may want to change this line
Glad you figured out you’re problem!
ShyFlooo
(Flo)
March 25, 2021, 8:10pm
#7
Oh great, you found the problem yourself
XBLAX
(XBLAX)
March 25, 2021, 8:15pm
#8
For those curious, the problem was that the .CharacterAdded event fires as soon as the Character is assigned to the player. By this point the Character model is parented to nil, so you should wait for the character to be reparented to the Workspace before continuing