Here is the script:
Runner.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then local p = game.Players:getPlayerFromCharacter(hit.Parent) if p.leaderstats.Class.Value == "Gunner" then p.leaderstats.Class.Value = "Runner" if p.leaderstats.Class.Value == "Runner" then p.Character:FindFirstChild("Humanoid").WalkSpeed.Value = 24 if p.StarterGear.Tool ~= nil then p.StarterGear.Tool:Destroy() end end end end end)
The error is at line 9 and the outputs returns me: Workspace.Runner.Script:9: attempt to index field 'WalkSpeed' (a number value)
What is the error and how can I fix it?
Well your problem is simple. You're trying to use WalkSpeed as though it was an IntValue, when in reality, WalkSpeed is actually a property of Humanoid.
Here's the fixed version of your code:
Runner.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then local p = game.Players:getPlayerFromCharacter(hit.Parent) if p.leaderstats.Class.Value == "Gunner" then p.leaderstats.Class.Value = "Runner" if p.leaderstats.Class.Value == "Runner" then p.Character:FindFirstChild("Humanoid").WalkSpeed = 24 if p.StarterGear.Tool ~= nil then p.StarterGear.Tool:Destroy() end end end end end)