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

Argument 1 missing or nil on my story game code from Ponchokings ?

Asked by
Puppynniko 1059 Moderation Voter
2 years ago

I've tried redoing it in a new baseplate but that does not work, the first time I did this it worked but I accidentally deleted the gameScript now it gives Argument 1 missing or nil

  17:16:52.756  Argument 1 missing or nil  -  Server - gameScript:10
  17:16:52.756  Stack Begin  -  Studio
  17:16:52.756  Script 'ServerScriptService.gameScript', Line 10 - function getPlayerImage  -  Studio - gameScript:10
  17:16:52.756  Script 'ServerScriptService.gameScript', Line 78 - function challenge_1  -  Studio - gameScript:78
  17:16:52.756  Script 'ServerScriptService.gameScript', Line 128 - function startGame  -  Studio - gameScript:128
  17:16:52.756  Script 'ServerScriptService.gameScript', Line 136  -  Studio - gameScript:136
  17:16:52.756  Stack End  -  Studio

this is the code that break it

local randomPlayerName
local randomPlayerId

local function getPlayerImage(player_id)
    local content, isReady = game:GetService("Players"):GetUserThumbnailAsync(player_id, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
    return content
end

local function getRandomPlayer()
    local players = game.Players:getPlayers()
    local number = math.random(1,#players)
    local randomPlayer = players[number]
    randomPlayerName = randomPlayer.Name
    randomPlayerId = randomPlayer.UserId
end

idk why it broke it worked the first time but broke at the second time I copied this from Ponchokings Video The link he gave my CreateDialogueEvent:

local player = game.Players.LocalPlayer
local CreateDialogueEvent = game.ReplicatedStorage.CreateDialogueEvent
local DialogueFrame = player.PlayerGui.ScreenGui.Frame

local function playSound(sound_id) -- Plays typing sound
    local sound = Instance.new("Sound",game.ReplicatedStorage)
    sound.SoundId = sound_id
    sound.Volume = .1
    sound.PlayOnRemove = true
    sound:Destroy()
end

local function textAnimate(content) -- Animates each letter
    for i=1,string.len(content) do
        DialogueFrame.TextLabel.Text = string.sub(content,1,i)
        playSound("rbxassetid://915576050")
        if string.sub(content,i,i) == "!" or string.sub(content,i,i) == "." or string.sub(content,i,i) == "?" then
            wait(1)
        elseif  string.sub(content,i,i) == "," then
            wait(.5)
        else
            wait(.05)
        end
    end
end

CreateDialogueEvent.OnClientEvent:Connect(function(image_id, content) -- activates when called from the Server
    if not player:findFirstChild("secretEnding") then
        DialogueFrame.ImageLabel.Image = image_id
        DialogueFrame.TextLabel.Text = ""
        DialogueFrame.Visible = true
        textAnimate(content)
    end
end)

Ponchokings code my gameScript code

local CreateDialogueEvent = game.ReplicatedStorage.CreateDialogueEvent
local TimerEvent = game.ReplicatedStorage.TimerEvent

-- Other Useful Functions

local randomPlayerName
local randomPlayerId

local function getPlayerImage(player_id)
    local content, isReady = game:GetService("Players"):GetUserThumbnailAsync(player_id, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
    return content
end

local function getRandomPlayer()
    local players = game.Players:getPlayers()
    local number = math.random(1,#players)
    local randomPlayer = players[number]
    randomPlayerName = randomPlayer.Name
    randomPlayerId = randomPlayer.UserId
end

----------------------------------------

-- put your challenge functions here
local function move()
    local npc = game.Workspace.Teacher

    local point1 = game.Workspace.Checkpoint1
    local point2 = game.Workspace.Checkpoint2
    local point3 = game.Workspace.Checkpoint3
    local point4 = game.Workspace.Checkpoint4
    local point5 = game.Workspace.Checkpoint5
    local point6 = game.Workspace.Checkpoint6
    local point7 = game.Workspace.Checkpoint7

    npc.Humanoid:MoveTo(point1.Position)
    npc.Humanoid:MoveTo(point2.Position)
    npc.Humanoid:MoveTo(point3.Position)
    npc.Humanoid:MoveTo(point4.Position)
    npc.Humanoid:MoveTo(point5.Position)
    npc.Humanoid:MoveTo(point6.Position)
    npc.Humanoid:MoveTo(point7.Position)
end

local function checkIfPlayerSit()
    for i,v in pairs(game.Players:GetPlayers()) do
        if v.Character then
            if v.Character.Humanoid.Sit ~= true then
                v.Character.Humanoid.Health = 0
            end
        end
    end
end

local function challeng_example() -- THIS IS JUST AN EXAMPLE! IT WON'T RUN
    local teacher_Image = "http://www.roblox.com/asset/?id=8447539851"
    wait(10)
    CreateDialogueEvent:FireAllClients(teacher_Image,"Hello Students!")
    wait(5)
    getRandomPlayer()
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"I think this is the School!")
end

local function challenge_intro()
    local teacher_Image = 'http://www.roblox.com/asset/?id=8447539851'
    CreateDialogueEvent:FireAllClients(teacher_Image,"Hello Students!")
    wait(2)
    CreateDialogueEvent:FireAllClients(teacher_Image,"Come in the class")
    wait(5)
    CreateDialogueEvent:FireAllClients(teacher_Image,"sit on the chair please")
    TimerEvent:FireAllClients(10)
    wait(10)
    checkIfPlayerSit()
end

local function challenge_1()
    local teacher_Image = 'http://www.roblox.com/asset/?id=8447539851'
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"I heard there was a ghost here")
    wait(2)
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"Wait really?")
    wait(2)
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"It was the ghost of the janitor")
    wait(2)
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"theres no way thats true")
    wait(2)
    CreateDialogueEvent:FireAllClients(teacher_Image,"Attention class, Theres no such things as ghost")
    wait(2)
    game.Lighting.Ambient = Color3.new(0.176471, 0.176471, 0.176471)
    game.Lighting.TimeOfDay = "1:00:00"
    game.Lighting.Brightness = 3
    game.Lighting.FogEnd = 50
    game.Lighting.FogStart = 10
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"Huh wheres the light")
    wait(5)
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"oh no is it the ghost")
    wait(2)
    CreateDialogueEvent:FireAllClients(teacher_Image,"Its probrobly not ill go check it")
    wait(2)
    CreateDialogueEvent:FireAllClients(teacher_Image,"stay here dont go anywhere")
    wait(3)
    move()
    game.Workspace["Huge Scream"]:play()
    wait(2)
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"What was that")
    wait(2)
end

local function challenge_2()

end

local function challenge_3()

end

local function challenge_4()

end

local function challenge_ending()

end

--------------------------------------------------

local function startGame() -- This is your main function where we order the challenges
    challenge_intro()
    challenge_1()
    challenge_2()
    challenge_3()
    challenge_4()
    challenge_ending()
end

wait(10) -- waits 10 seconds
startGame() -- runs the startGame function

Ponchokings code ask me if you need question cuz this is my first time posting a long question Thanks in Advance

0
you have to call the function btw i use ponchokings tutorial for all my story games and his timer script dosn't work just a heads up super00rocket 27 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

You didn't fire the function getRandomPlayer() to get the player's UserId. It was only fired in the challenge example function, which isn't called in the code at all. Try firing it in the other challenge function that got called in the code.

Ad

Answer this question