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

Whats wrong with this Gui Script?

Asked by
IcyEvil 260 Moderation Voter
10 years ago

Im trying to make it where if "On" is clicked it Teleports you to a certain point In Game but right now it is not Working, Any Help?

function click(mouse)
local human = game.Players:GetChildren()
if human then
    local humanoid = human:findFirstChild("Humanoid")
    if humanoid then
        human.Torso.CFrame = CFrame.new(-47.52, 106.53, 40.24)
    end
end
end
script.Parent.MouseButton1Down:connect(click)

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

human in your code is a Table, not a specific Player. Additionally, the Player's Character is where their physical parts - limbs and the Humanoid - are stored, not the Player itself.

I'm assuming this is a LocalScript:

function click(mouse)
local human = game.Players.LocalPlayer.Character
if human then
    local humanoid = human:findFirstChild("Humanoid")
    if humanoid then
        human.Torso.CFrame = CFrame.new(-47.52, 106.53, 40.24)
    end
end
end
script.Parent.MouseButton1Down:connect(click)
0
Thank You! IcyEvil 260 — 10y
Ad

Answer this question