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

attempt to index local 'data' (a number value)?

Asked by 5 years ago

I keep getting this error and I dont know why I don care if you just give me the fix but I would prefer to know why its happening and how to fix it myself

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)

heres the other part of the script in case its needed

local CAS = game:GetService("ContextActionService")

local RE = game:GetService("ReplicatedStorage"):WaitForChild("RE")

local fill = script.Parent:WaitForChild("Top"):WaitForChild("fill")

local stam = 50

local speed = 16

local function sprint(str, state, object)

speed = state == Enum.UserInputState.Begin and 24 or 16

RE:FireServer("sprint", (speed))

end

CAS:BindAction("sprint", sprint, true, Enum.KeyCode.LeftShift)

0
because data is a number, not an array theking48989987 2147 — 5y
0
and numbers dont have indexes theking48989987 2147 — 5y
0
See what I dont understand though is i was watching a video of someone doing it and it worked perfectly fine for him slysnake2000 0 — 5y
0
if you wanted (speed) to be an array, use {} rather than () (just for that part) theking48989987 2147 — 5y
View all comments (2 more)
0
OMG THANK YOU SO MUCH!!!!!!!! slysnake2000 0 — 5y
0
np :3 theking48989987 2147 — 5y

Answer this question