#Help me TO make the ball goes to what direction the screen are
1 messages · Page 1 of 1 (latest)
Raycast with screenpointtoray and in the client and sanity check in server thru remote event
yea i try it and when i shoot it its still doesnt go up
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local fill = player:WaitForChild("PlayerGui"):WaitForChild("PowerGui"):WaitForChild("PowerBar"):WaitForChild("Fill")
local replicatedStorage = game:GetService("ReplicatedStorage")
local shootEvent = replicatedStorage:WaitForChild("ShootBall")
local holding = false
local growSpeed = 1 -- how fast the bar fills (1 = 1 second to full)
local maxWidth = 1 -- full scale
local shrinkSpeed = 2 -- how fast it shrinks back
fill.Size = UDim2.new(0, 0, 1, 0) -- start empty
local power = 0 -- Track the shooting power
-- Function to shoot the ball
local function shootBall()
shootEvent:FireServer(power) -- Send power value to the server to shoot the ball
end
UIS.InputBegan:Connect(function(input, gpe)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
holding = true
while holding and fill.Size.X.Scale < maxWidth do
task.wait()
fill.Size = UDim2.new(math.clamp(fill.Size.X.Scale + growSpeed * 0.03, 0, maxWidth), 0, 1, 0)
power = fill.Size.X.Scale -- Update power based on Fill size
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
holding = false
-- Shrink bar back to 0
while fill.Size.X.Scale > 0 do
task.wait()
fill.Size = UDim2.new(math.clamp(fill.Size.X.Scale - shrinkSpeed * 0.03, 0, maxWidth), 0, 1, 0)
end
shootBall() -- Shoot when releasing M1
end
end)