I made some scripts that supposed to shoot a ball out of a player’s mouse. Its a tool. But no ball is created when i click my mouse.
Local: Inside the tool
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local hit = mouse.Hit
local event = game.ReplicatedStorage.throw
local canshoot = true
local tool = script.Parent
function OnActivation()
if canshoot == true then
canshoot = false
print('Activation works')
event:FireServer(hit)
wait()
canshoot = true
end
end
tool.Activated:Connect(OnActivation)
Server script: inside serverscript service
local storage = game.ReplicatedStorage
local event = storage.throw
local function onActivation(player, hit)
local root = hit
local ball = Instance.new("Part")
ball.Shape = Enum.PartType.Ball
ball.Color = Color3.new(0.133333, 0.133333, 0.133333)
ball.Size = Vector3.new(2,2,2)
ball.Material = Enum.Material.Grass
ball.CanCollide = false
ball.Parent = game.Workspace
local newCFrame = root
local cf = ball.CFrame
ball.CFrame = newCFrame
local Velocity = Instance.new("BodyVelocity")
Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
Velocity.Velocity = ball.CFrame.lookVector * 30
Velocity.Parent = ball
end
event.OnServerEvent:Connect(onActivation)
There are no errors in the output.
activation works prints