Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Need help with 2D platformer. Help?

Asked by 9 years ago

I am making a 2D platformer game, I have nailed the control and camera, I just need help with the teleport lava (Lava that TP's you to start) scripts. Currently I have this

1function onTouched(hit)
2    if hit.Parent:FindFirstChild("Humanoid") ~= nil then -- Because object "hit" is just "Left Leg" or "Right Leg"
3        game.Workspace.???.Torso.CFrame = CFrame.new(Vector3.new(-43, 10, 13))
4    end
5end
6 
7script.Parent.Touched:connect(onTouched)

The ??? is what I am stuck on. I need help on identifying a certain Instance by Name, not ClassName.

0
so this? game.Worksapce[hit.Parent].Torso.CFrame = CFrame.new(Vector3.new(-43, 10, 13)) lucas4114 607 — 9y
0
@lucas. When i replace with that, i recieve "Workspace.Part.Script:4: bad argument #2 to '?' (string expected, got Object)" bizarresox 10 — 9y
0
[hit.Parent.Name]* not [hit.Parent] lucas4114 607 — 9y

1 answer

Log in to vote
1
Answered by
Sublimus 992 Moderation Voter
9 years ago

If you are just trying to get the torso of the player that touched it, just use hit.Parent since that would point to the character object.

1function onTouched(hit)
2    if hit.Parent:FindFirstChild("Humanoid") ~= nil then -- Because object "hit" is just "Left Leg" or "Right Leg"
3        hit.Parent.Torso.CFrame = CFrame.new(Vector3.new(-43, 10, 13))
4    end
5end
6 
7script.Parent.Touched:connect(onTouched)
Ad

Answer this question