CFrame not working, doesn't move to right spot even with the right cframe, but no errors?
Asked by
6 years ago Edited 6 years ago
What does this script supposed to do -
when a child is added in the workspace, it will check the class name of it, if its a model then it will get the player using it, then it will get the value of the stage in the leaderstats of the player then it will find a part from game.workspace.checkpoints(folder) that is named same as the value of the stage in the leaderstats of the player then it will get it's cframe and move the humanoidrootpart of the obj(character) and move it 12 studs up.
1 | game.Workspace.ChildAdded:Connect( function (obj) |
2 | if obj.ClassName = = "Model" then |
3 | local player = game.Players:GetPlayerFromCharacter(obj) |
4 | local target = game.Workspace.CheckPoints:FindFirstChild(player.leaderstats.Stage.Value) |
5 | obj.HumanoidRootPart.CFrame = target.CFrame + Vector 3. new( 0 , 12 , 0 ) |
the error is that instead of finding the part with the name same as the value of the stage, it tries to find the STAGE in that folder
1 | 20 : 16 : 37.289 - Stage is not a valid member of Folder |
2 | 20 : 16 : 37.290 - Stack Begin |
3 | 20 : 16 : 37.291 - Script 'ServerScriptService.Script' , Line 4 |
4 | 20 : 16 : 37.292 - Stack End |
UPDATE - i found the error, so in the script where i made the leaderstats apparently it was lowercase "s" so i made it uppercase now it works, BUT not just yet, it doesn't teleport me to the right spot, i used print to see the cframe and it was right but it still doesn't teleport me to the right spot? i tried removing the vector3 but still doesn't work.