Hey everyone,
I hope you’re doing well. I’ve been working on a snowball script for my Roblox game, and I’ve run into a bit of a snag. While I’ve managed to resolve an earlier error, I’m now facing an issue where the snowball isn’t being thrown at the mouse position as intended. Instead, it simply appears at the mouse pointer.
Here’s a snippet of my current script:
local snowBall = script.Parent
local direction
script.Parent.PickenTarget.OnServerEvent:Connect(function(player, mouse)
direction = mouse
print(direction)
local function throw()
local Handle = snowBall.Handle
local newSnowBall = Handle:Clone()
newSnowBall.Parent = workspace
newSnowBall.CanTouch = false
newSnowBall.CanCollide = true
newSnowBall.Position = direction + direction.Unit * 3
local throwSpeed = 100
local throwDirection = (direction - newSnowBall.Position).unit
newSnowBall.AssemblyLinearVelocity = throwDirection * throwSpeed
print(direction)
end
snowBall.Activated:Connect(throw)
end)
Localscript:
local player =game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.Activatced:Connect(function()
script.Parent.PikenTarget:FireServer(mouse.Hit.p)
end)
I’ve tried debugging and tweaking the code, but I haven’t been successful in getting the snowball to follow the mouse trajectory upon release. If anyone has experience with this or could provide guidance on how to properly implement mouse position-based throwing for a snowball in Roblox, I would greatly appreciate it.