corrija os erros :   12:13:45.489  Players.CINRILO.Backpack.Slingshot.LocalScript:81: attempt to index nil with 'Play'  -  Cliente - LocalScript:81, e    12:13:46.753  Players.CINRILO.Backpack.Slingshot.LocalScript:91: attempt to index nil with 'Stop'  -  Cliente - LocalScript:91 desse script : local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local PullBackAnim, ReleaseAnim
local isAiming = false
local aimingStartTime
local trajectoryLine
local MAX_FORCE = 100 -- You can adjust this value to change the maximum force of the slingshot
local cooldown = 1 -- Cooldown in seconds
local lastShotTime = 0
local ammo = 10 -- Starting ammo, adjust as needed

-- Mobile support
local UIS = game:GetService("UserInputService")
local isMobile = UIS.TouchEnabled and not UIS.MouseEnabled

-- Animations
local humanoid = nil
local animator = nil

-- Sounds
local pullSound = tool:WaitForChild("PullSound")
local releaseSound = tool:WaitForChild("ReleaseSound")

-- RemoteEvent
local launchProjectileEvent = tool:WaitForChild("LaunchProjectile")

-- Function to create the trajectory line
local function createTrajectoryLine()
	trajectoryLine = Instance.new("Part")
	trajectoryLine.Anchored = true
	trajectoryLine.CanCollide = false
	trajectoryLine.Transparency = 0.5
	trajectoryLine.BrickColor = BrickColor.new("White")
	trajectoryLine.Material = Enum.Material.Neon
	trajectoryLine.Size = Vector3.new(0.2, 0.2, 0.2)
	trajectoryLine.Name = "TrajectoryLine"
	trajectoryLine.Parent = workspace
end

-- Function to update the trajectory line
local function updateTrajectoryLine(origin, direction, force)
	-- Clear previous line
	for _, part in pairs(workspace:GetChildren()) do
		if part.Name == "TrajectoryPart" and part:IsDescendantOf(workspace) then
			part:Destroy()
		end
	end

	local NUM_POINTS = 50
	local timeStep = 0.1
	local gravity = workspace.Gravity
	local lastPoint = origin

	for i = 1, NUM_POINTS do
		local t = i * timeStep
		local displacement = direction * force * t + 0.5 * Vector3.new(0, -gravity, 0) * t * t
		local currentPoint = origin + displacement

		local segment = Instance.new("Part")
		segment.Anchored = true
		segment.CanCollide = false
		segment.Transparency = 0.5
		segment.BrickColor = BrickColor.new("White")
		segment.Material = Enum.Material.Neon
		segment.Size = Vector3.new(0.1, 0.1, (currentPoint - lastPoint).magnitude)
		segment.CFrame = CFrame.new(currentPoint, lastPoint) * CFrame.new(0, 0, -segment.Size.Z / 2)
		segment.Name = "TrajectoryPart"
		segment.Parent = workspace
		lastPoint = currentPoint
	end
end

-- Function to handle aiming
local function startAiming()
	if tick() - lastShotTime < cooldown or ammo <= 0 then return end
	isAiming = true
	aimingStartTime = tick()
	createTrajectoryLine()
	pullSound:Play()
	PullBackAnim:Play()
end

-- Function to handle shooting
local function stopAiming()
	if not isAiming then return end
	isAiming = false
	lastShotTime = tick()
	ammo = ammo - 1
	releaseSound:Play()
	PullBackAnim:Stop()
	ReleaseAnim:Play()
	-- Calculate force based on how long the player held down
	local holdTime = math.min(tick() - aimingStartTime, 2)
	local force = holdTime / 2 * MAX_FORCE
	-- Get direction
	local character = player.Character or player.CharacterAdded:Wait()
	local origin = tool.Handle.Position
	local direction = (mouse.Hit.p - origin).Unit
	-- Fire projectile
	launchProjectileEvent:FireServer(origin, direction, force)
	-- Clear trajectory line
	for _, part in pairs(workspace:GetChildren()) do
		if part.Name == "TrajectoryPart" and part:IsDescendantOf(workspace) then
			part:Destroy()
		end
	end
end

-- Update loop
game:GetService("RunService").RenderStepped:Connect(function()
	if isAiming then
		local character = player.Character or player.CharacterAdded:Wait()
		local origin = tool.Handle.Position
		local direction = (mouse.Hit.p - origin).Unit
		local holdTime = math.min(tick() - aimingStartTime, 2)
		local force = holdTime / 2 * MAX_FORCE
		updateTrajectoryLine(origin, direction, force)
	end
end)

-- Input handlers
if isMobile then
	UIS.TouchStarted:Connect(function(input, gameProcessed)
		if tool.Parent == player.Character then
			startAiming()
		end
	end)
	UIS.TouchEnded:Connect(function(input, gameProcessed)
		if isAiming then
			stopAiming()
		end
	end)
else
	mouse.Button1Down:Connect(function()
		if tool.Parent == player.Character then
			startAiming()
		end
	end)
	mouse.Button1Up:Connect(function()
		if isAiming then
			stopAiming()
		end
	end)
end

-- Equip and Unequip handlers
tool.Equipped:Connect(function()
	humanoid = player.Character:WaitForChild("Humanoid")
	animator = humanoid:FindFirstChildOfClass("Animator") or humanoid:WaitForChild("Animator")
	-- Load animations
	PullBackAnim = animator:LoadAnimation(tool:WaitForChild("PullBack"))
	ReleaseAnim = animator:LoadAnimation(tool:WaitForChild("Release"))
end)

tool.Unequipped:Connect(function()
	isAiming = false
	-- Clear trajectory line
	for _, part in pairs(workspace:GetChildren()) do
		if part.Name == "TrajectoryPart" and part:IsDescendantOf(workspace) then
			part:Destroy()
		end
	end
end)