Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

CFrame touched not working "player.leaderstats.Stage.Value" part never works.. (?)

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
wait(0.1)
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(player.leaderstats.Stage.Value).CC.CFrame
	end
end)

i can't manage to get the actual value of the stage it says that you're on. Instead i currently have it like this for example:

game.Workspace:FindFirstChild("0").CC.CFrame

Please help in any way possible, ty for ur time!

2 comments

0

what error are you getting?

0

no error at all.. :/

3 answers

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
wait(0.1)
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(player.leaderstats.Stage.Value).CC.Position
    end
end)

try this

4 comments

0

doesn't work guess ill just have to stick to my shitty one :(

0

23:24:08.120 - Workspace.Stage 1.Part.Script:8: 'end' expected (to close 'function' at line 2) near ''

0

nvm fixed the error but still doesnt work, im actually getting really confused on why this isnt working, its supposed to be easy :(

0

No, you should try deleting the player entering script and the characteradded.

Try this, the problem could be that your stage value is a number and not a string.

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
wait(0.1)
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(tostring(player.leaderstats.Stage.Value)).CC.CFrame
    end
end)

Now if the player is on stage 1 they'll be teleported to a model or part named "1", but you can of course change this if you want.

1 comment

0

this makes every single player that dies teleport to the stage im on.. pls add my disc Fuze#4779

Why not just use a teleport instead of CFrame? It would be much easier to do especially with.Touched!

This discussion is preserved as it was. New answers, comments, and votes are closed.