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

How can I select the player in a teleportation script?

Asked by
Swolcu 2
4 years ago

I'm new to scripting and I am trying to make a teleportation script, but I don't know how to reach the character on line 19. It says, "Head is not a valid member of Workspace." Please help.

button = script.Parent.buttonframe.TextButton
gui = script.parent.Frame
telebutton = gui["tele to red"]
platform = game.Workspace.teleplatform

gui.Visible = false

button.MouseButton1Down:connect(function()
    if gui.Visible == false then
        gui.Visible = true

    else
        gui.Visible = false
    end
end)

telebutton.MouseButton1Down:connect(function()
    if gui.Visible == true then
        game.Workspace.Head.CFrame = target.CFrame*CFrame.new("-16.139, 4.048, 42.141")
    end
end)

1 answer

Log in to vote
0
Answered by 4 years ago

What function/event would I use to solve this?

If you didn't know, there is a function called WaitForChild(). What this function does is it will wait for the child (The items inside of the item) to load.

This method is commonly used to get a part from a character.

Examples

Here's some examples.

local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local Character = player.Character or player.CharacterAdded:Wait()

local Head =  character:WaitForChild('Head')

Conclusion

This way, you can ask the script to wait for the object inside of something.

I hope you learned something today! Have a nice day! ;)

0
Thanks for replying! How do I incorporate this into the script though? I am even more confused lol Swolcu 2 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
View all comments (75 more)
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, what you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
0
So uh, when you're defining a thing, try and use :WaitForChild() more often. Sensei_Developer 298 — 4y
Ad

Answer this question