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

What is wrong with Line 4?

Asked by 10 years ago
function onButton1Down(mouse) 
local w = game.Workspace:GetChildren() 
local i = 1, #w do 
local (w[i].className == "Camera") or (w[i].className == "Cam" .. game.Players.LocalPlayer.Character.Name) then 
local w[i].CameraSubject == game.Players.LocalPlayer.Character.Humanoid then                                              




local[i].CameraSubject = game.Workspace.SpaceShuttle.SpaceShuttle.Orbiter:findFirstChild("Camera1") 
local[i].CameraType = "Track"
local[i].Name = "Cam" .. game.Players.LocalPlayer.Character.Name 
local[i].CameraSubject = game.Players.LocalPlayer.Character.Humanoid
w[i].CameraType = "Custom"
end 
end 
end 
end 


function onSelected(mouse) 
mouse.Button1Down:connect(onButton1Down) 
end 

script.Parent.Selected:connect(onSelected) 


1 answer

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

You keep using local which messes up the script. It's supposed to be used for variables such as local a = game.Workspace.Part. You also forgot the 'if' in the if statement at line 4.

function onButton1Down(mouse) 
    local w = game.Workspace:GetChildren() 
    for i = 1, #w do
        if w[i].className == "Camera" or w[i].className == "Cam"..game.Players.LocalPlayer.Character.Name then 
            if w[i].CameraSubject == game.Players.LocalPlayer.Character.Humanoid then                                              
                w[i].CameraSubject = game.Workspace.SpaceShuttle.SpaceShuttle.Orbiter:findFirstChild("Camera1") 
                w[i].CameraType = "Track"
                w[i].Name = "Cam" .. game.Players.LocalPlayer.Character.Name 
                w[i].CameraSubject = game.Players.LocalPlayer.Character.Humanoid
                w[i].CameraType = "Custom"
            end 
        end 
    end 
end 


function onSelected(mouse) 
    mouse.Button1Down:connect(onButton1Down) 
end 

script.Parent.Selected:connect(onSelected) 
Ad

Answer this question