RemoteEvent detection help

This local script fires a RemoteEvent inside the local script in StarterPlayerScripts:

Mouse.Button1Up:Connect(function()
	MouseDown = false
	shootingCD = true
	if Power == 0 then
		print("yo")
		script.HasShot:FireServer(Power)
		wait(2)
		shootingCD = false
	elseif Power == 1 then
		print("yo")
		script.HasShot:FireServer(Power)
		
		Power = 0
		wait(2)
		shootingCD = false
	elseif Power == 2 then
		print("yo")
		script.HasShot:FireServer(Power)
		Power = 0
		wait(2)
		shootingCD = false
	elseif Power == 3 then
		print("yo")
		script.HasShot:FireServer(Power)
		Power = 0
		wait(2)
		shootingCD = false
	end

But the script that detects when the RemoteEvent has been activated doesn’t work. Heres that script:

script.Parent.OnServerEvent:Connect(function(Power)
	print("Worked")
	if Power == 1 then
		print("1 Fired")
	end
	if Power == 2 then
		print("2 Fired")
	end
	if Power == 3 then
		print("3 Fired")
	end
end)

The spelling is all correct, I’m sure theres something I’m missing to make the script detect the RemoteEvent .

Here is what the explorer looks like:
Setup

What I want to achieve is allowing the script to detect when the RemoteEvent is fired.

I don’t think Regular scripts work in StarterPlayerScripts, so maybe put the RemoteEvent in ReplicatedStorage and the script in ServerScriptService and change the code around to match the new locations, also

script.Parent.OnServerEvent:Connect(function(Power)

Will not work because the first parameter is always the player, so it has to be

script.Parent.OnServerEvent:Connect(function(player, Power)

Of course, you’ll have to change script.Parent in your code to the location of it in ReplicatedStorage

@Jackscarlett Fair enough, reference is always handy

3 Likes

script.Parent.OnServerEvent:Connect(function(Player, Power)

Idc if I’m late I’m just giving reference

3 Likes