Hey developers!
I am creating a Spirit Bomb script, I want it to go where the player’s mouse is (it’s supposed to go to the ground), I tried to do it but is becoming hard, can someone help?
Hey developers!
I am creating a Spirit Bomb script, I want it to go where the player’s mouse is (it’s supposed to go to the ground), I tried to do it but is becoming hard, can someone help?
Put this in a local script, then you could use a remote event to tell the server to place the bomb:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
wait(5)
mouse.Button1Up:Connect(function()
local mouseray = mouse.UnitRay
local ignorelist = {} --you can leave blank, but put anything here you want the ray to ignore
local castray = Ray.new(mouseray.Origin, mouseray.Direction * 1000) --create a ray from the mouse
local hit, position = workspace:FindPartOnRayWithIgnoreList(castray, ignlist)
if hit then
print(hit) --will print what the mouse is pointing toward
print(position) --will print the position of the mouse in the workspace
--run code to place bomb, maybe like:
--local bombclone = game.ReplicatedStorage.Bomb:Clone()
-- bombclone.Position = position
end
end)