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

OnServerEvent not triggering?

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

4 comments

0

Arg, I dunno if it helps, but replace workspace with game.Worksapce.

0

@ChemicalHex Just workspace works fine too.

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.

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

1 answer

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.

1 comment

0

Doesn't work.

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