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
local player = script.Parent.Parent.Parent local mouse = player:GetMouse() script.Parent.Activated:Connect(function() local kaboom = Instance.new("Explosion",workspace) kaboom.Position = mouse.Hit.Position end)
Thanks to @Shawnyg, you get set the player in a LocalScript
with the LocalPlayer
property in the Players service.
local playerServ = game:GetService("Players") -- Get the players service local player = playerServ.LocalPlayer -- Use the LocalPlayer property local mouse = player:GetMouse() script.Parent.Activated:Connect(function() local kaboom = Instance.new("Explosion",workspace) kaboom.Position = mouse.Hit.Position end)