Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

So my remote event doesn't fire, does anybody know why?

Local Script:

function onshoot()
	if game.ReplicatedStorage.GunSwapBool.Value == true and game.ReplicatedStorage.PistolEquipped.Value == true and not reloading and not notshooting then
		print("shooting")

		shooting = true
		
		pistolammo.Value = pistolammo.Value -1
		
		workspace.pistolfire:Play()

		track:Play()

		muzzleflash.FlashGui.Flash.Visible = true

		workspace.Camera.CFrame = workspace.Camera.CFrame * CFrame.Angles(math.rad(0.5),0,0)


		local gunray = Ray.new(muzzleflash.Position, (mouse.Hit.p - muzzleflash.Position).unit * 990)

		local part, pos = workspace:FindPartOnRayWithIgnoreList(gunray, {workspace.CurrentCamera, game.Players.LocalPlayer.Character})
		
		if part then
			game.ReplicatedStorage.RemoteEventPistol:FireServer(part, pos)
		end
	end
end


mouse.Button1Down:Connect(function()
	onshoot()
end)

Script:

pistolevent.OnServerEvent:Connect(function(plr, part, pos)
	if part.Parent:FindFirstChild("Humanoid") then
		local humanoid = part.Parent.Humanoid

		if humanoid.Health > 0 and part.Name == "Head" then

			humanoid:TakeDamage(90)

			wait(0.1)
			
			print("Edamage")
			
			humanoid:TakeDamage(100)

	
		elseif humanoid.Health > 0 and part.Name ~= "Head" then
			humanoid:TakeDamage(30)
			print("Edamage")
		end
	else

		local bullet = Instance.new("Part")
		bullet.BrickColor = BrickColor.new("Black")
		bullet.Size = Vector3.new(0.1,0.1,0.1)
		bullet.Position = pos
		bullet.Anchored = true
		bullet.CanCollide = false
		bullet.Parent = workspace.bullets

		debris:AddItem(bullet, 2)
	end
end)

4 comments

0

Can you add a print in the serverscript to test if it really works or not?

0

yah

0

ill try that

0

it doesn't print

2 answers

✓ Accepted answer

Don't put effects in a local script. This is because others can't see those effects. Name the remote event in the both the scripts and in the actual game the same name.

Fixed it I put a unnecessary repeat loop at the beginning.

This discussion is preserved as it was. New answers, comments, and votes are closed.