Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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)
0
Can you add a print in the serverscript to test if it really works or not? rabbi99 714 — 3y
0
yah ABCTrainerDude 12 — 3y
0
ill try that ABCTrainerDude 12 — 3y
0
it doesn't print ABCTrainerDude 12 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

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.

Ad
Log in to vote
0
Answered by 3 years ago

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

Answer this question