Hello people,
Just like the title says, how can i get the projectiles to shoot at mouse position because when i use mouse.Hit.p
it shows the position relative to the world. Also I am using a tool and server events to pass the necessary information
Server Script (tool handler script):
tool.Activated:Connect(function()
local pos
mouseEvent.OnServerEvent:Connect(function(plr, mouseHit)
print(mouseHit)
pos = mouseHit
end)
local ball = ss.Projectiles.FireBall:Clone()
local bv = Instance.new("BodyVelocity")
ball.CFrame = script.Parent.Handle.CFrame
bv.Velocity = ball.CFrame.lookVector * speed
bv.Parent = ball
ball.Parent = game.Workspace.Projectiles
end)
Local Script:
local Character = Player.Character or Player.CharacterAdded:Wait()
local mouseEvent = game.ReplicatedStorage.Events.GetMousePosEvent
local debounce = false
Character.ChildAdded:Connect(function(NewChild)
if NewChild:IsA("Tool") then
if NewChild.Name == "Wand" then
debounce = true
local mouse = Player:GetMouse()
mouseEvent:FireServer(mouse.Hit.p)
end
end
end)
Character.ChildRemoved:Connect(function(RemovedChild)
if RemovedChild:IsA("Tool") then
if RemovedChild.Name == "Wand" then
debounce = false
end
end
end)
Ask me if anything is necessary, thx for the help!