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

attempt to index global 'yourRemoteEvent' (a nil value) Why tho?

Asked by 5 years ago

So I'm trying to add a shift to sprint script but it keeps stopping after a few seconds so I tried this to maybe fix it but now im getting this

game:GetService("UserInputService").InputBegan:Connect(function(input) -- Input Began checks if the play presses anything and fires whenever the player does so

if input.KeyCode == Enum.KeyCode.LeftShift then -- Detects LS press

-- Fire a remote event

yourRemoteEvent:FireServer()

end

end)

game:GetService("UserInputService").InputEnded:Connect(function(input)

--Send another remote event to stop Bool Value when enabled

end)

This is also my sprint script in case it can be fixed in there instead

-- Define Vars

local player = game.Players.LocalPlayer

local Character = player.Character

local UserInputService = game:GetService("UserInputService")

local Speed = 25

-- Script

UserInputService.InputBegan:Connect(function(key)

if key.KeyCode == Enum.KeyCode.LeftShift then

Character.Humanoid.WalkSpeed = Speed

-- Do This Scrpt

end

end)

UserInputService.InputEnded:Connect(function(key)

if key.KeyCode == Enum.KeyCode.LeftShift then

Character.Humanoid.WalkSpeed = 16

end

end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You're not defining what 'yourRemoteEvent' really is. It's just... a nil variable. To fix your problem your going to need to set a variable to the remoteevent before actually calling on it.

0
Thanks I ended up going with a different sprint script because I wanted it to take away stamina also but now im getting this error attempt to index local 'data' (a number value) slysnake2000 0 — 5y
0
this is the full script its from local RE = game:GetService("ReplicatedStorage"):WaitForChild("RE") RE.OnServerEvent:connect(function(player, request, data) if request == "sprint" then player.Character.Humanoid.WalkSpeed = data(1) end end) slysnake2000 0 — 5y
0
your 2nd argument on the client side needs to be data and not a nil value AnonymousDeveloper13 22 — 5y
Ad

Answer this question