|
| 28 Jul 2011 12:07 AM |
local ScopeIsOn = false local cam = game.Workspace.CurrentCamera local tool = script.Parent local player = game.Players.LocalPlayer tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) key = key:lower() if key == "z" then if ScopeIsOn == false then wait() local ScopeBrick = Instance.new("Part") ScopeBrick.Name = "ScopeBrick" ScopeBrick.Size = Vector3.new(4,4,4) ScopeBrick.Transparency = 1 ScopeBrick.Anchored = true ScopeBrick.CanCollide = false if mouse.Target == nil then return end ScopeBrick.CFrame = player.Character.Torso.CFrame.lookVector * 100 --Here is the error [ Line 18 ] cam.CameraSubject = ScopeBrick cam.CameraType = "Attach" ScopeIsOn = true local gui = tool.scopeGui:Clone() gui.Parent = player.PlayerGui elseif ScopeIsOn == true then for _,v in pairs(game.Workspace:GetChildren()) do if v.Name == "ScopeBrick" then game.GetService("Debris"):AddItem(v,0.01) end end cam.CameraSubject = player.Character.Humanoid cam.CameraType = "Custom" player.PlayerGui.scopeGui:Remove() ScopeIsOn = false end end end) end)
--Output is Players.TigerBloodd.Backpack..Scope:18: bad argument #3 to '?' (CFrame expected, got userdata)
The hierarchy is
-Tool --MainShooting (LocalScript --Scope (LocalScript --scopeGui ---Scope --Handle ---Mesh |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
|
| 28 Jul 2011 12:22 AM |
idk..
a=false cam=nil gui = script.Window1
function onEquipped(mouse2) mouse2.KeyDown:connect(onkeyDown) mouse = mouse2 end function onkeyDown(key) if key == "z" then if not a then cam=game.Workspace.CurrentCamera:clone() cam.Parent=game.Workspace game.Workspace.CurrentCamera.CameraSubject = mouse.Target game.Workspace.CurrentCamera.CameraType=4
g = gui:Clone() player = game.Players["" ..script.Parent.Parent.Name] g.Parent = player.PlayerGui
a=true else game.Workspace.CurrentCamera.CameraSubject=game.Players.LocalPlayer.Character game.Workspace.CurrentCamera:Remove() game.Workspace.CurrentCamera=cam
if g ~= nil then g:remove() end
a=false end end end
script.Parent.Equipped:connect(onEquipped)
|
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 12:23 AM |
| Thats not yours... Im asking you to fix mine. |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 12:24 AM |
| Oh okay stop being so mean.. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
kension19
|
  |
| Joined: 17 Jan 2008 |
| Total Posts: 6964 |
|
|
| 28 Jul 2011 12:29 AM |
| Instead of using .CFrame = Torso.LookVector * 100, perhaps .Position? =o |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 12:32 AM |
Kk;
How do i rotate a camera? |
|
|
| Report Abuse |
|
|
kension19
|
  |
| Joined: 17 Jan 2008 |
| Total Posts: 6964 |
|
|
| 28 Jul 2011 12:37 AM |
workspace.CurrentCamera.CoordinateFrame = CFrame.new(x,y,z)
Just give it a subject, and it'll take care of itself in terms of what direction it's pointing. |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 12:40 AM |
local ScopeIsOn = false local cam = game.Workspace.CurrentCamera local tool = script.Parent local player = game.Players.LocalPlayer tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) key = key:lower() if key == "z" then if ScopeIsOn == false then wait() local ScopeBrick = Instance.new("Part") ScopeBrick.Name = "ScopeBrick" ScopeBrick.Size = Vector3.new(4,4,4) ScopeBrick.Transparency = 1 ScopeBrick.Anchored = true ScopeBrick.CanCollide = false if mouse.Target == nil then return end ScopeBrick.CFrame = player.Character.Torso.CFrame + Vector3.new(0,0,100) cam.CameraSubject = ScopeBrick cam.CameraType = "Attach" ScopeIsOn = true local gui = tool.scopeGui:Clone() gui.Parent = player.PlayerGui elseif ScopeIsOn == true then for _,v in pairs(game.Workspace:GetChildren()) do if v.Name == "ScopeBrick" then game.GetService("Debris"):AddItem(v,0.01) end end cam.CameraSubject = player.Character.Humanoid cam.CameraType = "Custom" player.PlayerGui.scopeGui:Remove() ScopeIsOn = false
end end end) end)
Try that. |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 12:44 AM |
@Flappy; That works 1 direction, I need it to work the way my torso is facing |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Jul 2011 12:47 AM |
local ScopeIsOn = false local cam = game.Workspace.CurrentCamera local tool = script.Parent local player = game.Players.LocalPlayer tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) key = key:lower() if key == "z" then if ScopeIsOn == false then wait() local ScopeBrick = Instance.new("Part") ScopeBrick.Name = "ScopeBrick" ScopeBrick.Size = Vector3.new(4,4,4) ScopeBrick.Transparency = 1 ScopeBrick.Anchored = true ScopeBrick.CanCollide = false if mouse.Target == nil then return end ScopeBrick.CFrame = player.Character.Torso.lookVector cam.CameraSubject = ScopeBrick cam.CameraType = "Attach" ScopeIsOn = true local gui = tool.scopeGui:Clone() gui.Parent = player.PlayerGui elseif ScopeIsOn == true then for _,v in pairs(game.Workspace:GetChildren()) do if v.Name == "ScopeBrick" then game.GetService("Debris"):AddItem(v,0.01) end end cam.CameraSubject = player.Character.Humanoid cam.CameraType = "Custom" player.PlayerGui.scopeGui:Remove() ScopeIsOn = false
end end end) end) |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 12:48 AM |
Fail....
local ScopeIsOn = false local cam = game.Workspace.CurrentCamera local tool = script.Parent local player = game.Players.LocalPlayer tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) key = key:lower() if key == "z" then if ScopeIsOn == false then wait() local ScopeBrick = Instance.new("Part") ScopeBrick.Name = "ScopeBrick" ScopeBrick.Size = Vector3.new(4,4,4) ScopeBrick.Transparency = 1 ScopeBrick.Anchored = true ScopeBrick.CanCollide = false if mouse.Target == nil then return end ScopeBrick.CFrame = player.Character.Torso.lookVector * 100 cam.CameraSubject = ScopeBrick cam.CameraType = "Attach" ScopeIsOn = true local gui = tool.scopeGui:Clone() gui.Parent = player.PlayerGui elseif ScopeIsOn == true then for _,v in pairs(game.Workspace:GetChildren()) do if v.Name == "ScopeBrick" then game.GetService("Debris"):AddItem(v,0.01) end end cam.CameraSubject = player.Character.Humanoid cam.CameraType = "Custom" player.PlayerGui.scopeGui:Remove() ScopeIsOn = false
end end end) end)
Try that. |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2011 12:51 AM |
| Thats what i started with... |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Jul 2011 12:54 AM |
I did; Output was..
Workspace.TigerBloodd.1.Scope:18: bad argument #3 to '?' (CFrame expected, got userdata)
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 28 Jul 2011 01:03 AM |
| Tiger, you RayCast, too? :D |
|
|
| Report Abuse |
|
|
| |
|