How can I make this work for a custom character?

Hello,
I’m trying to make a projectile with a custom character, but it doesn’t seem to work and I know it works with a default character. So what do I need to change for it to work?
Script:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(Player)
	local Character = Player.Character
	
	local Projectile = Instance.new("Part")
	Projectile.Parent = workspace
	Projectile.Position = Character.Blaster.Position + Character.Blaster.CFrame.LookVector * 2
	Projectile.CanCollide = false
	Projectile.Shape = Enum.PartType.Ball
	Projectile.Size = Vector3.new(2.5,2.5,2.5)
	Projectile.Material = Enum.Material.Neon
	Projectile.Color = Color3.new(0.686275, 0.435294, 0)
	
	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.Parent = Projectile
	BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	BodyVelocity.Velocity = Character.Blaster.CFrame.LookVector * 100

	wait(1)
	Projectile.Color = Color3.new(0, 0, 0)
	BodyVelocity:Destroy()
end)

Thank you any help is appreciated.

What’s the issue, why doesn’t it work?

It doesn’t seem to be firing. I tried using prints and it didn’t fire.

Can you add prints()'s and see where it stops?

Here’s the fire:

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Event = script:WaitForChild("RemoteEvent")
local Debounce = false

Mouse.Button1Down:Connect(function()
	if not Debounce then
		Debounce = true
		Event:FireServer(Player)
		wait(1)
		Debounce = false
	end
end)

and anything after doesn’t fire.

Where does it stop exactly, in that script?

The event does not fire that’s where it stops.

Since you’re saying the event doesn’t fire, the debounce is most likely your issue here.

local Debounce = false

if Debounce then return end
Debounce = true
Event:FireServer(Player)
wait(1)
Debounce = false

Edit –
You don’t need to send the player instance by the way (from the client in your FireServer() function), since the first parameter of OnServerEvent will be the player instance that fired the RemoteEvent.

Still doesn’t print when supposedly fired.

Try adding a print on the first line after OnServerEvent, see if that prints.

As I said before I did and it doesn’t print

Any errors? It shouldn’t just “stop” as you said.
I can’t really help you if you believe the script just stops after the debounce part.

Wait I’m just wondering should I put it in Starter Player or Starter Character I placed it in starter player before I think it’s starter character, right?

Doesn’t really matter where the script is, preferrably in StarterPlayerScripts or StarterGui.

No I mean starter character or starter player in starter player?
Screenshot 2021-10-28 165246

As I said it doesn’t really matter, but preferrably in StarterPlayerScripts or StarterGui.

1 Like

After testing, I realized it only works in starter character, so thank you for helping I know it’s kind of let down since it’s not really the coding part, so sorry for wasting your time.

1 Like

No worries, glad you figured out the issue after all!

1 Like