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

Can someone tell me why this script doesnt turn the player into my custom character?

Asked by 5 years ago

So I have been trying to make a Piggy like a game but my code just won't cooperate I have made a script called game logic and 2 module scripts in it called RoundModule and EventHandling can you tell me why the code doesn't allow the player to become my custom character? here is the game logic script

01local Round = require(script.RoundModule)
02Round.intermisiion(25)
03local chosenChapter = Round.SelectChapter()
04 
05local clonedChapter = chosenChapter:Clone()
06clonedChapter.Name = "Map"
07clonedChapter.Parent = game.Workspace
08local Contestants = {}
09 
10for i, v in pairs(game.Players:GetPlayers()) do
11    if not v:FindFirstChild("InMenu") then
12        table.insert(Contestants,v)
13    end
14end
15 
View all 27 lines...

here is RoundModule script

01local module = {}
02 
03local status = game.ReplicatedStorage:WaitForChild("Status")
04function module.intermisiion(length)
05    for i =length,0,-1 do
06        status.Value = "Next round starts in "..i.." seconds"
07        wait(1)
08    end
09end
10 
11function module.SelectChapter()
12    local rand = Random.new()
13    local chapters = game.ReplicatedStorage.Chapters:GetChildren()
14    local chosenChapter = chapters[rand:NextInteger(1,#chapters)]
15 
View all 33 lines...

the event handling one has no code right now so I won't show it, and the errors that show are 15:48:32.758 - ServerScriptService.Game Logic.RoundModule:23: attempt to index function with 'NextInteger',and 15:48:32.759 - Script 'ServerScriptService.Game Logic', Line 16 can you tell me what this problem is?

1 answer

Log in to vote
1
Answered by 5 years ago

Hello!

Issue

You forgot to call the Random.new function.

Fix

Simply add a () to your RoundModule ModuleScript.

Fixed RoundModule ModuleScript

01local module = {}
02 
03local status = game.ReplicatedStorage:WaitForChild("Status")
04function module.intermisiion(length)
05    for i =length,0,-1 do
06        status.Value = "Next round starts in "..i.." seconds"
07        wait(1)
08    end
09end
10 
11function module.SelectChapter()
12    local rand = Random.new()
13    local chapters = game.ReplicatedStorage.Chapters:GetChildren()
14    local chosenChapter = chapters[rand:NextInteger(1,#chapters)]
15 
View all 33 lines...

Please accept this answer if it helped!

0
wow thx ayuu_ondev 60 — 5y
Ad

Answer this question