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

OnServerEvent not triggering?

Asked by
drew1017 330 Moderation Voter
9 years ago

Client:

uiS.InputBegan:connect(function(input, processed)
        if input.KeyCode == Enum.KeyCode.LeftShift and Alive then -- (Hold) Shift: Sprinting, 20% increase in move speed
            workspace.Comm.InGamePlayerAction:FireServer(player, 'BeganSprinting')
                print'w0w' -- Prints successfully
        end
    end)

Server:

workspace.Comm.InGamePlayerAction.OnServerEvent:connect(function(player, action)
        print'accepted' -- Does not print
        if action == 'BeganSprinting' then
            print'started sprinting' -- Does not sprint
        end
    end)

Pretty self explanatory, the OnServerEvent isn't being triggered. halp

0
Arg, I dunno if it helps, but replace workspace with game.Worksapce. ChemicalHex 979 — 9y
0
@ChemicalHex Just workspace works fine too. RepeatLua 90 — 9y
0
Also, it looks like you don't know what the "processed" argument is. It's basically if the CoreScripts should handle it. If you press a key in chat, backpack or anything similar, processed will be true. RepeatLua 90 — 9y
0
Check to see if your if statement is actually going through since I made some minor adjustment and it seems to work perfectly find here for example. http://prntscr.com/9eamyf UserOnly20Characters 890 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You shouldn't define the player argument as it's default.

Client:

uiS.InputBegan:connect(function(input, processed)
        if input.KeyCode == Enum.KeyCode.LeftShift and Alive then -- (Hold) Shift: Sprinting, 20% increase in move speed
            workspace.Comm.InGamePlayerAction:FireServer('BeganSprinting')
                print'w0w' -- Prints successfully
        end
    end)

The code above is not tested, but should work.

0
Doesn't work. drew1017 330 — 9y
Ad

Answer this question