so im having some issues, this script is a regular script in a tool it keeps saying that mouse is a nil value
heres the code that i made
1 | local player = script.Parent.Parent.Parent |
2 | local mouse = player:GetMouse() |
3 |
4 | script.Parent.Activated:Connect( function () |
5 | local kaboom = Instance.new( "Explosion" ,workspace) |
6 | kaboom.Position = mouse.Hit.Position |
7 | end ) |
Thanks to @Shawnyg, you get set the player in a LocalScript
with the LocalPlayer
property in the Players service.
1 | local playerServ = game:GetService( "Players" ) -- Get the players service |
2 | local player = playerServ.LocalPlayer -- Use the LocalPlayer property |
3 | local mouse = player:GetMouse() |
4 |
5 | script.Parent.Activated:Connect( function () |
6 | local kaboom = Instance.new( "Explosion" ,workspace) |
7 | kaboom.Position = mouse.Hit.Position |
8 | end ) |