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

Problem with Line 6?!

Asked by 9 years ago

Hi there! I made a Teleport GUI. And everything I made was perfect but ever since I put the ScreenGui to ReplicatedStorage because I only want it to myself. Anyway I'm having trouble in Line 6 of this Script:

spawn = game.Workspace.HouseArea
player = script.Parent.Parent.Parent.Parent

local funtcion onClicked()
    local spawnArea = game.Workspace.HouseArea;
    local playerList = game.Players:GetChildren; --It keeps saying function arguments expected near ":"
    local playerToTeleport = nil;

    for key, value in pairs(playerList) do
        playerToTeleport = game.Workspace:FindFirstChild(value.Name);
        if playerToTeleport ~= nill then
            player.Torso.CFrame = CFrame.new(spawnArea.Position);
        end
    end
end

script.Parent.MouseButton1Down:connect(onClicked)

Please Help

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

GetChildren is a method, meaning you have to call it -- it will have parenthesis immediately after it.

local playerList = game.Players:GetChildren()

Parenthesis enclose the function's arguments which is what that error was requesting you provide.


You are recommended to use :GetPlayers() instead of :GetChildren() since it is more semantically meaningful.

0
Sir now i have problem in Line 15 CjGamer1454 0 — 9y
Ad

Answer this question