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
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Script Repair Help?

Previous Thread :: Next Thread 
iiPhantomBlue is not online. iiPhantomBlue
Joined: 12 Mar 2010
Total Posts: 113
23 Jun 2016 07:34 PM
Okay so I'm making an FPS game and this is my camera controlling script, but when I click play and test it it does not follow the mouse properly. Any help is reallllly appreciated.




wait(.5)
_G.RecoilY = 0
_G.RecoilX = 0
_G.MouseSensitivity = .1
_G.PrimarySensitivity = .1
_G.SecondarySensitivity = .1
_G.TertiarySensitivity = .1

_G.Target = nil
_G.Zoomed = false
--game.StarterGui:SetCoreGuiEnabled("Health", false)
local RunService = game:GetService("RunService")
local RenderStepped = RunService.RenderStepped
local UserInputService = game:GetService("UserInputService")
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
UserInputService.MouseIconEnabled = false
--
local Player = game.Players.LocalPlayer
local myChar = Player.Character
Player.CameraMode = "LockFirstPerson"
local Mouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
Camera.CameraType = "Custom"
Camera.FieldOfView = 70
Camera.CameraType = "Custom"
Camera:ClearAllChildren()
repeat wait() until Player.Character ~= nil
repeat wait() until Player.Character:FindFirstChild("Head") ~= nil
_G.Target = Player.Character.Head
--[[stuff = Player.Character:GetChildren()
for i = 1, #stuff do
thing = stuff[i]
if thing:IsA("Hat") then
thing:remove()
end
end]]
xangle = 0
yangle = 0

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
Camera.CameraType = "Scriptable"
UserInputService.InputChanged:connect(function(inputObject)
local inputObject = inputObject
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
local XChange, YChange = inputObject.Delta.X, inputObject.Delta.Y
if _G.Zoomed == true then
xangle = xangle + YChange*0.005*_G.MouseSensitivity
yangle = yangle + XChange*0.005*_G.MouseSensitivity
else
xangle = xangle + YChange*0.005
yangle = yangle + XChange*0.005
end
newxangle = xangle
if -xangle+_G.RecoilX > math.rad(89) then
xangle = -math.rad(89)
_G.RecoilX = 0
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle,0,0)
elseif -xangle+_G.RecoilX < -math.rad(89) then
xangle = math.rad(89)
_G.RecoilX = 0
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle,0,0)
else
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle+_G.RecoilX,0,0)
end


local MDir = Camera.CoordinateFrame.lookVector--mouse.UnitRay.Direction.unit
local RotTarget = Vector3.new(MDir.x,0,MDir.z)
local cfYaw = CFrame.new(myChar.HumanoidRootPart.Position,myChar.HumanoidRootPart.Position + RotTarget)
myChar.HumanoidRootPart.CFrame = cfYaw
end
end)

RenderStepped:connect(function()
if -xangle+_G.RecoilX > math.rad(89) then
xangle = -math.rad(89)
_G.RecoilX = 0
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle,0,0)
elseif -xangle+_G.RecoilX < -math.rad(89) then
xangle = math.rad(89)
_G.RecoilX = 0
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle,0,0)
else
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle+_G.RecoilX,0,0)
end
local MDir = Camera.CoordinateFrame.lookVector--mouse.UnitRay.Direction.unit
local RotTarget = Vector3.new(MDir.x,0,MDir.z)
local cfYaw = CFrame.new(myChar.HumanoidRootPart.Position,myChar.HumanoidRootPart.Position + RotTarget)
myChar.HumanoidRootPart.CFrame = cfYaw
end)


--iiPhantomBlue--
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
23 Jun 2016 07:36 PM
> Posts wall of code
> Doesn't define what the script is supposed to be doing and what is happening instead.
Report Abuse
iiPhantomBlue is not online. iiPhantomBlue
Joined: 12 Mar 2010
Total Posts: 113
23 Jun 2016 07:46 PM
Oh sorry, first time posting here. It's basically supposed to make your camera follow your mouse in firstperson when you're holding a gun. I can give a link to the place so you can see the issue I'm talking about a little better?


--iiPhantomBlue--
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
23 Jun 2016 07:48 PM
Please do. If it's the first place I don't see the problem.
Report Abuse
iiPhantomBlue is not online. iiPhantomBlue
Joined: 12 Mar 2010
Total Posts: 113
23 Jun 2016 07:49 PM
https://www.roblox.com/games/154630600/Operation-Blox
It's this one.


--iiPhantomBlue--
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
23 Jun 2016 07:49 PM
"The permission levels on this place prevent you from entering."
Report Abuse
iiPhantomBlue is not online. iiPhantomBlue
Joined: 12 Mar 2010
Total Posts: 113
23 Jun 2016 07:51 PM
Fixed.


--iiPhantomBlue--
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
23 Jun 2016 07:53 PM
Nope.
Report Abuse
iiPhantomBlue is not online. iiPhantomBlue
Joined: 12 Mar 2010
Total Posts: 113
23 Jun 2016 07:55 PM
It's on "Everyone" is able to access..and the max players is 18. Idk.


--iiPhantomBlue--
Report Abuse
virulent_phantom is not online. virulent_phantom
Joined: 13 Jun 2011
Total Posts: 470
23 Jun 2016 07:56 PM
so, you're trying to do recoil?
try out camera rotation
if you want it to be smooth, then just do a for i loop,
also do a coroutine so it doesn't slow down the fire rate of your gun
Report Abuse
TheGrayHat is not online. TheGrayHat
Joined: 02 May 2014
Total Posts: 523
23 Jun 2016 07:57 PM
Alright, it let me in.
Report Abuse
iiPhantomBlue is not online. iiPhantomBlue
Joined: 12 Mar 2010
Total Posts: 113
23 Jun 2016 07:57 PM
virulent can you join me? It's really hard to explain this in this thread.


--iiPhantomBlue--
Report Abuse
virulent_phantom is not online. virulent_phantom
Joined: 13 Jun 2011
Total Posts: 470
23 Jun 2016 07:57 PM
god dang it i didn't even read it all the way though..
man
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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