This projectile script doesn't work! HELP!

This projectile script doesn’t work! HELP! There are no errors in the output. The projectile never appears in the workspace when I click on the screen.
Client Script –

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")

local remoteEvent = ReplicatedStorage:WaitForChild("TapRequest")

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if not gameProcessedEvent and input.UserInputType == Enum.UserInputType.MouseButton1 then
		local mouse = game.Players.LocalPlayer:GetMouse()
		local tapPosition = mouse.Hit.p
		remoteEvent:FireServer(tapPosition)
	end
end)

Server Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("TapRequest")

remoteEvent.OnServerEvent:Connect(function(player, tapPosition)
	local spinnerTemplate = ReplicatedStorage:WaitForChild("spinner")

	local newSpinner = spinnerTemplate:Clone()
	newSpinner.Parent = game.Workspace
	newSpinner.Position = player.Character:WaitForChild("HumanoidRootPart").Position
	local direction = (tapPosition - newSpinner.Position).unit
	local initialVelocity = 50
newSpinner.Anchored = false
	newSpinner.Velocity = direction * initialVelocity

	newSpinner.Touched:Connect(function(otherPart)
		local character = otherPart.Parent
		if character:IsA("Model") and character:FindFirstChild("Humanoid") and not character then
			local humanoid = character:FindFirstChild("Humanoid")
			humanoid:TakeDamage(25)
		end
		newSpinner:Destroy()
	end)

	wait(2)
	newSpinner:Destroy()
end)

Your projectile is appearing, but it is being destroyed instantly because it is touching your character’s HumanoidRootPart (note you position the spinner at the local player’s HumanoidRootPart’s position and then have a touched event that destroys it when it gets touched). You’ll want to add an if statement in your touched event to prevent this.

1 Like