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

When I spawn I get 0 walkspeed. Help Please?

Asked by 7 years ago

When I spawn I get 0 walkspeed not 100. :(

Regular Script

local Character_Settings = require(game.ServerStorage:WaitForChild("Settings"):WaitForChild("Character_Settings"))

game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(Character)
        Character:FindFirstChildOfClass("Humanoid").WalkSpeed = Character_Settings.WalkSpeed
    end)
end)

Module Script

local module = {}

local WalkSpeed = 100

return module

1 answer

Log in to vote
0
Answered by
Uglypoe 557 Donator Moderation Voter
7 years ago

Notice how at the bottom of the ModuleScript, it says return module. This will return that table named 'module' at the top of the script. However, you didn't edit that table at all. While you did declare a variable 'WalkSpeed', you didn't declare it within the table, so when you use require() on the module, it won't return that variable.

You can fix it by adding the WalkSpeed variable to the table in the module. I've done this below:

local module = {}

module.WalkSpeed = 100

return module

If you need any more help, feel free to ask! -Poe

Ad

Answer this question