Sorry If this is in the wrong topic.
I’m planning on making a new project based on throwable tools. I’ve managed to make a ball which flies where you click, but the problem is it isn’t mobile friendly. Tapping where I want it to hit only fires it in one direction, and I’m not sure what I need to add/include to make it work identically to how it works on PC.
Code:
Local Script
local SuperBloxyBall = script.Parent
local FireBallEvent = game.ReplicatedStorage.FireBall
local Debounce = false
SuperBloxyBall.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function() ---Pretty sure this doesn't work on mobile correctly
if not Debounce then
Debounce = true
FireBallEvent:FireServer(SuperBloxyBall.Handle.Position, Mouse.Hit.p) --Mouse.Hit.p the issue?
else
wait(2)
Debounce = false
end
end)
end)
Server Script
local FireBallEvent = game.ReplicatedStorage.FireBall
local Speed = 500
local db = false
FireBallEvent.OnServerEvent:Connect(function(player, HandlePos, MouseHitPos)
local SuperBloxyBall = game.ServerStorage.ToClone:Clone()
SuperBloxyBall.Name = "Ball"
SuperBloxyBall.Position = HandlePos
SuperBloxyBall.Parent = workspace
local distance = (MouseHitPos - HandlePos).Magnitude
SuperBloxyBall.CFrame = CFrame.new(HandlePos, MouseHitPos) --Set Clone's CFrame
SuperBloxyBall.Velocity = SuperBloxyBall.CFrame.LookVector * Speed --The firing of the ball, the part that doesn't work how I'd like it to
SuperBloxyBall.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(1)
end
end)
end)
Help much appreciated