Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When I spawn I get 0 walkspeed. Help Please?

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.