my script
math.randomseed(tick()) local ReplicatedStorage = game:GetService("ReplicatedStorage") local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage) punchEvent.Name = "PunchEvent" local animations = (2729957815) local function onPunchFired(plr) local char = game.Workspace:FindFirstChild(plr.Name) local humanoid = char.Humanoid local animation = Instance.new("Animation") animation.AnimationId = "http://roblox.com/asset/?id="..animations[math.random(1, #animations)] local animTrack = humanoid:LoadAnimation(animations) animTrack:Play() end punchEvent.OnServerEvent:Connect(onPunchFired)
the error
20:28:03.324 - ServerScriptService.Punch:13: attempt to get length of upvalue 'animations' (a number value)
how do i fix this plss help
Silly mistake you made. You did this:
local animations = (2729957815)
Which gets evaluated as
local animations = 2729957815
Therefore, animations
is a number value. When you try to index it later on, it throws an error.
20:28:03.324 - ServerScriptService.Punch:13: attempt to get length of upvalue 'animations' (a number value)
To fix this, do what kingdom5 said and replace your ()
with {}
or curly brackets. This tells Lua that you're making a table.