I'm new to Roblox Lua, but I do have experience in other languages including C, C++, Java, Python. I'm having a problem with this localscript. I want the localscript to work like this: When a player touches this block it changes the camera view to somewhere else. Instead of doing that it changes the camera view for ALL the players in the server. Here is the localscript: (It is in StarterGui)
local cam = workspace.Camera
local player = game.Players.LocalPlayer
local focus = game.Workspace.col1
local tween = game:GetService("TweenService")
local active = false
game.Workspace.Shop.Touched:Connect(function(hit)
if not active then
active = true
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local root = hit.Parent:FindFirstChild("HumanoidRootPart")
Iterator = 1
if humanoid ~= nil then
humanoid.WalkSpeed = 0
cam.CameraType = Enum.CameraType.Scriptable
local ts = TweenInfo.new(0.0001,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0)
local Goals = {CFrame = focus.CFrame}
local move = tween:Create(cam,ts,Goals)
move:Play()
if root ~= nil then
root.CFrame = game.Workspace.queue.CFrame
end
wait(0.5)
local buttons = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local back = Instance.new("ImageButton")
local front = Instance.new("ImageButton")
local home = Instance.new("TextButton")
buttons.Name = "buttons"
buttons.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
buttons.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
Frame.Parent = buttons
Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Frame.BackgroundTransparency = 1.000
Frame.Size = UDim2.new(0, 100, 0, 100)
back.Name = "back"
back.Parent = Frame
back.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
back.Position = UDim2.new(0, 0, 3.05000019, 0)
back.Size = UDim2.new(0, 73, 0, 84)
back.Rotation = 180.000
back.Image = "http://www.roblox.com/asset/?id=4726772330"
back.BackgroundTransparency = 1
front.Name = "front"
front.Parent = Frame
front.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
front.Position = UDim2.new(11.1300001, 0, 3.05000019, 0)
front.Size = UDim2.new(0, 73, 0, 84)
front.Image = "http://www.roblox.com/asset/?id=4726772330"
front.BackgroundTransparency = 1
home.Name = "home"
home.Parent = Frame
home.BackgroundColor3 = Color3.fromRGB(244, 80, 255)
home.Position = UDim2.new(4.91000032, 0, 7.48000002, 0)
home.Size = UDim2.new(0, 267, 0, 66)
home.Font = Enum.Font.SourceSans
home.Text = "Back Home"
home.TextColor3 = Color3.fromRGB(0, 0, 0)
home.TextScaled = true
home.TextSize = 14.000
home.TextWrapped = true
player.PlayerGui.buttons.Frame.home.MouseButton1Click:Connect(function(player)
cam.CameraType = Enum.CameraType.Custom
script.Parent.buttons:Destroy()
humanoid.WalkSpeed = 16
Iterator = 1
end)
script.Parent.buttons.Frame.front.MouseButton1Click:Connect(function(player)
if Iterator <= 4 then
Iterator = Iterator + 1
local count = tostring(Iterator)
local val = "col"..count
local focus2 = game.Workspace:WaitForChild(tostring(val))
local ts2 = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0)
local Goals2 = {CFrame = focus2.CFrame}
local move2 = tween:Create(cam,ts2,Goals2)
move2:Play()
else
Iterator = 0
end
end)
end
wait(2)
active = false
end
end)

4 comments
use workspace.CurrentCamera, not Camera
That script is a listener for events happening. Whenever the block is touched, doesn't matter who touched it, it will run on all clients. Try changing to to a server script and getting the player from the character.
@killerbrenden good idea, i didnt think of that
@killerbrenden It works when I make it into a script but it will not change the cameratype to scriptable even when I tell it to, the cameratype remains custom