What is wrong with my script?

I got a script where I throw a ball but it’s a local script and I would like it to become a server script.

I tried to convert local player = game.Players.LocalPlayer to the Player Added function to get mouse but it seems to not be working.

local player = game:GetService("Players").LocalPlayer
local character = player.Character
local mouse = player:GetMouse()
local handle = script.Parent.Handle
local debounce = false

local track
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://11440701567"

script.Parent.Activated:Connect(function()
	if not debounce then
		debounce = true
		track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
		track.Priority = Enum.AnimationPriority.Action
		track.Looped = false
		track:Play()
		script.Parent.Boing:Play()
		local Handle = handle:Clone()
		Handle.Parent = workspace
		Handle.CFrame = Handle.CFrame * CFrame.new(0, 2, 0)
		Handle.Trail.Enabled = true
		local direction = mouse.Hit.LookVector
		local forceMultipliter = 250 * Handle:GetMass()
		Handle:ApplyImpulse(direction * forceMultipliter)
		wait(0.25)
		debounce = false
	end
end)

I only need help to convert the ball throwing part.

Heya, this has already been answered here.

Like all forms of input, the player’s Mouse exists only on their client. It cannot be passed to the server for this reason. Instead of passing the mouse itself to the server, why not pass whichever property that the server needs to it? For example, if the server needs the mouse’s hit position, simply pass that directly:

event:FireServer(mouse.Hit)
2 Likes

Ok I’ll try this and I’ll reply again if it worked

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.