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

Why isn't this teleporting the character to its new position?

Asked by 9 years ago

I have a morph (which becomes the players torso). on the center of the morph (which is the characters torso) I have a click detector and script. It is supposed to teleport the player, once the morph (which is still the characters torso) is clicked, to the given coordinates. Why isn't it teleporting? Are you not able to add click detectors to morphs/players torso?

local player = game.Players.LocalPlayer
local char =player.Character.Torso

function Click() 
    char.CFrame = CFrame.new(Vector3.new(-107.28, 2.88, 90.1))
end 

script.Parent.MouseButton1Down:connect(Click) 

--most of this was taken from somebody else's script--

0
You need to tell us the nam e of the part and the click detector and thnigs like that. tumadrina 179 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago
function Click()                                                                 
    game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(0,0,0) --change to your position
end 
script.Parent.MouseButton1Down:connect(Click)

First, the variables are not needed for this script. Using game.Players.LocalPlayer.Character.Torso.CFrame is easier, or you can use char = game.Players.LocalPlayer.Character.Torso

Second, I have no Idea why you are using Vector3, but the CFrame is correct.

Last, please use your own scripts.

Tip: add 3 digits to the middle number of your CFrame. ( Example: -50,50,-90. The middle number is 50. Add three you got 53 so put that there so you don't glitch out when you teleport there.

Please +1 or accept if this helped!

Ad
Log in to vote
0
Answered by
tumadrina 179
9 years ago
local Player = game.Players.LocalPlayer 
repeat wait() until
Player.Character--You need to wait for the Character(Unless you're in play solo)
local Char =Player.Character.Torso 
local Mouse=game.Players.LocalPlayer:GetMouse()
function Click()  
    Char.CFrame = CFrame.new(Vector3.new(-107.28, 2.88, 90.1))
end 
Mouse.Button1Down:connect(Click) --Its Button1Down, notMouseButton1Down

It worked well at my place It is a localscript which is in StarterPack (if you press F9 the errors are from a different script.)

0
Neither of these worked, thanks though! yogipanda123 120 — 9y

Answer this question