So, I've been working on a script that activates increases your speed when you press Left Shift. I've recently been trying to just get print statements to work so that I know something being transferred over the RemoteEvent I set up. Well, the print statement doesn't work, and the output is left blank. So, here's the code inside StarterPlayerScripts:
local userInputService = game:GetService("UserInputService") local player = game.Players.LocalPlayer local event = game.ReplicatedStorage:WaitForChild("SprintEvent") if userInputService.InputBegan and userInputService.KeyboardEnabled then userInputService.InputBegan:connect(function(inputObject) if inputObject == Enum.KeyCode.LeftShift then event:FireServer("SprintBegan") end end) elseif userInputService.InputEnded and userInputService.KeyboardEnabled then userInputService.InputEnded:connect(function(inputObject) if inputObject == Enum.KeyCode.LeftShift then event:FireServer("SprintEnded") end end) end
and here's the test script inside ServerScriptService:
local sprintEvent = game.ReplicatedStorage:WaitForChild("SprintEvent") sprintEvent.OnServerEvent:connect(function(...) local tuple = {...} if tuple[1] == "SprintBegan" then print("Sprint Began") elseif tuple[1] == "SprintEnded" then print("Sprint Ended") end end)
OnServerEvent
always takes the player as its first argument, THEN the other arguments.
local sprintEvent = game.ReplicatedStorage:WaitForChild("SprintEvent") sprintEvent.OnServerEvent:connect(function(player, ...) local tuple = {...} if tuple[1] == "SprintBegan" then print("Sprint Began") elseif tuple[1] == "SprintEnded" then print("Sprint Ended") end end)