generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Help!

Previous Thread :: Next Thread 
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
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
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:10 AM
Bump
Report Abuse
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:14 AM
Bump T_T Help!
Report Abuse
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:18 AM
Bump
Report Abuse
TheBeastsup11 is not online. TheBeastsup11
Joined: 19 Jun 2011
Total Posts: 142
28 Jul 2011 12:21 AM
what is it..
Report Abuse
TheBeastsup11 is not online. TheBeastsup11
Joined: 19 Jun 2011
Total Posts: 142
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
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:23 AM
Thats not yours... Im asking you to fix mine.
Report Abuse
TheBeastsup11 is not online. TheBeastsup11
Joined: 19 Jun 2011
Total Posts: 142
28 Jul 2011 12:24 AM
Oh okay stop being so mean..
Report Abuse
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:26 AM
It didn't work either.
Report Abuse
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:28 AM
Bump
Report Abuse
kension19 is not online. 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
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:32 AM
Kk;

How do i rotate a camera?
Report Abuse
kension19 is not online. 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
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
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
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:44 AM
@Flappy;
That works 1 direction, I need it to work the way my torso is facing
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
28 Jul 2011 12:46 AM
Oh, I'm sorry.
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
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
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
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
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:51 AM
Thats what i started with...
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
28 Jul 2011 12:52 AM
No. Just try it.
Report Abuse
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
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
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 12:58 AM
Bump T_T
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
28 Jul 2011 01:01 AM
Try, Position?
Report Abuse
FlappydavidINC is not online. FlappydavidINC
Joined: 20 May 2011
Total Posts: 694
28 Jul 2011 01:03 AM
Tiger, you RayCast, too? :D
Report Abuse
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
28 Jul 2011 01:06 AM
Hell ya lol
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image