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
 

Re: local mouse = plr:GetMouse() bug???/

Previous Thread :: Next Thread 
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
23 Aug 2016 08:41 PM
So basically what my script does is when you click the key `, it shoots a brick called "FirebBall" at the location of the players Mouse. The problem is that whenever my mouse is hovering over a brick and sometime terrain, it gives faulty mouse location readings so instead of shooting at the brick or terrain, it shoots to the side of it. Here's my scripts, hopefully I can get a solution. If you have the time to test this out yourself, pay attention to the printed coordinates of the mouse. You'll notice a huge jump of hundreds if not thousands when moving the mouse from right above a brick, to on a brick.

Following is a local script in a textbutton which is located in the players PlayerGuis.

local contextActionService = game:GetService("ContextActionService")

Move = script.Parent



function onKeyPress(actionName, userInputState, inputObject)
plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
if userInputState == Enum.UserInputState.Begin then
MouseLocation = (mouse.Hit.p)
print (MouseLocation)
print ("Localscript Mouse^^^")
game.Workspace.MyMovesRemoteFunction:InvokeServer({"FireBall", MouseLocation})
end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Backquote)

--------------------

Next is a ServerScript located in Workspace.

local myRemoteFunction = Instance.new("RemoteFunction")
myRemoteFunction.Parent = game.Workspace
myRemoteFunction.Name = "MyMovesRemoteFunction"
function myRemoteFunction.OnServerInvoke(player,message)

print (player.Name)
print (message[1])
print (message[2])
print ("Mouse^^")


if message[1] == ("FireBall") then
print ("Is FireBall")

plr = game.Players:WaitForChild(player.Name)

FireBall = Instance.new("Part")
FireBall.Shape = ("Ball")
FireBall.FormFactor = 3
FireBall.Size = Vector3.new(1, 1, 1)
FireBall.Parent = game.Workspace
FireBall.CanCollide = true
FireBall.Anchored = false
FireBall.Name = ("FireBall")
FireBall.BrickColor = BrickColor.new("Bright red")

Fire = Instance.new("Fire")
Fire.Parent = FireBall

FireBall.CFrame = CFrame.new(plr.Character.Torso.Position)
print (FireBall.CFrame)
print (message[2])
print ("Mouse2^^")

direction = (message[2]).unit
spawnPos = plr.Character.Torso.Position + direction * 2.0

FireBall.Velocity = direction * 100.0
FireBall.RotVelocity = Vector3.new(0, 10, 0)


local floatForce = Instance.new("BodyForce")
floatForce.force = Vector3.new(0, FireBall:GetMass() * 196.1, 0)
floatForce.Parent = FireBall
delay(5,function() floatForce:Destroy() end)




print ("FireBall creation complete")

end




end




Report Abuse
IandoIakes is not online. IandoIakes
Joined: 03 Jul 2016
Total Posts: 872
23 Aug 2016 09:29 PM
dont use keydown use userinputservice

much better for handling commends on a key press
Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
24 Aug 2016 07:20 AM
Bump
Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
24 Aug 2016 07:27 AM
plr isn't local
Report Abuse
Mitko0o1 is not online. Mitko0o1
Joined: 30 Nov 2010
Total Posts: 5725
24 Aug 2016 07:29 AM
Open the output and paste the error, lookinf for script mistages in a large code is like finding a needle in a haystack.


am triggered
Report Abuse
thatkidog is not online. thatkidog
Joined: 17 Aug 2006
Total Posts: 14
24 Aug 2016 07:44 AM
make local plr = game:GetService("Players").LocalPlayer


Also this script is much like a laser script which roblox has a tutorial with using RayCasting,

Here it is
http://wiki.roblox.com/index.php?title=Making_a_ray-casting_laser_gun


Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
24 Aug 2016 08:27 AM
There are no errors. The only thing worth seeing in the output os the print of the mouse location which jumos by thousands when over a brick or terrain.
Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
24 Aug 2016 08:30 AM
Youtube video (guess you can't show output but just try my scripts if you want to try and help solve the issue.) - https://www.youtube.com/edit?video_id=3lf2ASALP-8
Report Abuse
puppyboy803 is not online. puppyboy803
Joined: 28 Nov 2008
Total Posts: 1458
24 Aug 2016 05:12 PM
Correct youtube link - https://www.youtube.com/watch?v=3lf2ASALP-8
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