For some reason, my ModuleScript is erroring because of the player.
Server Script:
for i, player in pairs(game.Players:GetPlayers()) do
table.insert(players, player)
print(player.Name)
end
mainModule:StartPlayers(players)
And my module script code:
function module.StartPlayers(players)
local spawnPoints = map:WaitForChild("SpawnPoints")
local spawns = spawnPoints:GetChildren()
wait(5)
for i, player in pairs(players) do
if player then
character = player.Character
if character then
--Morph
local chosenMorph = game.ServerStorage.Tornado
for _, v in pairs(character:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 1
elseif v:IsA("Accessory") then
v:Destroy()
end
end
local clonedMorph = chosenMorph:Clone() --Creating morph
clonedMorph.Parent = character
clonedMorph.Name = player.Name.."_Tornado"
local morphWeld = Instance.new("Weld")--Welding morph to player
morphWeld.Parent = clonedMorph --Use tornado part or whatever here!
morphWeld.Part1 = clonedMorph --Same here!
morphWeld.Part0 = character:FindFirstChild("HumanoidRootPart")
character.Humanoid.WalkSpeed = chosenMorph.Speed.Value
character.Humanoid.JumpPower = 0
--Teleport
character:FindFirstChild("HumanoidRootPart").CFrame = spawns[1].CFrame + Vector3.new(0,12,0)
table.remove(spawns, 1)
end
end
end
end
It errors at character = player.Character
Error: "Character is not a valid member of Model"
Oddly enough, making it character = workspace:FindFirstChild(player.Name) fixes that error, but then it errors at 'character.Humanoid.WalkSpeed = chosenMorph.Speed.Value' saying that "Humanoid is not a valid member of Model"
How do I fix this? Also, is there a way to have, sort of a global table for all of the players that any script can access? That would make coding easier.

2 comments
Well, I didn't include the full server script, it waits before running all of this. Also, on your third point, what do you mean by that? I only have about 5 months of experience XD
Also, using a colon seemed to fix the issue.