Script help for a story game

Can you send me the variables you defined without sending the pictures?

Use the lua formatted text implemented into the dev forum
yourcodepic

‘’’
local CreateDialogueEvent = game.ReplicatedStorage.CreateDialogueEvent

local npc = game.Workspace.Max

local point1 = game.Workspace.Point1

local point2 = game.Workspace.Point2

local point3 = game.Workspace.Point3

local point4 = game.Workspace.Point4

local point5 = game.Workspace.Point5

local point6 = game.Workspace.Point6

– 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 challeng_example() – THIS IS JUST AN EXAMPLE! IT WON’T RUN

local Max_Image = “rbxassetid://4841171880”

CreateDialogueEvent:FireAllClients(Max_Image,“”)

wait(5)

getRandomPlayer()

CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),“”)

end

local function challenge_intro()

local Max_Image = “rbxassetid://6790923696”

local Emma_Image = “rbxassetid://6791199409”

CreateDialogueEvent:FireAllClients(Max_Image,“Hello friends, today we will go on a city trip!”)

wait(5)

GetWinEvent:FireAllClients()

wait(5)

getRandomPlayer()

CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),“Yay, we can go so much fun stuff in this city.”)

wait(5)

CreateDialogueEvent:FireAllClients(Max_Image,“Lets go to our hotel”)

wait(5)

npc.Humanoid:MoveTo(point1.Position)

npc.Humanoid.MoveToFinished:Wait()

npc.Humanoid:MoveTo(point2.Position)

npc.Humanoid.MoveToFinished:Wait()

npc.Humanoid:MoveTo(point3.Position)

npc.Humanoid.MoveToFinished:Wait()

npc.Humanoid:MoveTo(point4.Position)

npc.Humanoid.MoveToFinished:Wait()

CreateDialogueEvent:FireAllClients(Max_Image,“This is our hotel guys.”)

wait(5)

CreateDialogueEvent:FireAllClients(Max_Image,“Lets go inside”)

wait(5)

npc.Humanoid:MoveTo(point5.Position)

npc.Humanoid.MoveToFinished:Wait()

npc.Humanoid:MoveTo(point6.Position)

npc.Humanoid.MoveToFinished:Wait()

wait(3)

GetWinEvent:FireAllClients()

CreateDialogueEvent:FireAllClients(Emma_Image,“Welcome to emma’s hotel, how can I help you?”)

wait(5)

CreateDialogueEvent:FireAllClients(Max_Image,“We want to check in. We reserved a room for so much people.”)

wait(10)

CreateDialogueEvent:FireAllClients(Emma_Image,“One big room, okay sir, you have been checked in, I hope you enjoy your stay here, we will now clean your room.”)

wait(14)

CreateDialogueEvent:FireAllClients(Max_Image,“Okay, thank you miss, okay guys, lets explore the city. come back when it will get dark.”)

wait(15)

getRandomPlayer()

CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),“Okay max, we promise we will come back before its dark.”)

wait(5)

end

local function challenge_1_Night1()

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_Night1()

challenge_2_()

challenge_3_()

challenge_4_()

challenge_ending()

end

wait(10) – waits 10 seconds

startGame() – runs the startGame functionprint(“Hello world!”)

‘’’

Sir, you forgot to put lua at the front of your “```” (no space)

local CreateDialogueEvent = game.ReplicatedStorage.CreateDialogueEvent

local npc = game.Workspace.Max

local point1 = game.Workspace.Point1

local point2 = game.Workspace.Point2

local point3 = game.Workspace.Point3

local point4 = game.Workspace.Point4

local point5 = game.Workspace.Point5

local point6 = game.Workspace.Point6

-- 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 challeng_example() -- THIS IS JUST AN EXAMPLE! IT WON'T RUN

local Max_Image = "rbxassetid://4841171880"

CreateDialogueEvent:FireAllClients(Max_Image,"")

wait(5)

getRandomPlayer()

CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"")

end

local function challenge_intro()

local Max_Image = "rbxassetid://6790923696"

local Emma_Image = "rbxassetid://6791199409"

CreateDialogueEvent:FireAllClients(Max_Image,"Hello friends, today we will go on a city trip!")

wait(5)

GetWinEvent:FireAllClients()

wait(5)

getRandomPlayer()

CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"Yay, we can go so much fun stuff in this city.")

wait(5)

CreateDialogueEvent:FireAllClients(Max_Image,"Lets go to our hotel")

wait(5)

npc.Humanoid:MoveTo(point1.Position)

npc.Humanoid.MoveToFinished:Wait()

npc.Humanoid:MoveTo(point2.Position)

npc.Humanoid.MoveToFinished:Wait()

npc.Humanoid:MoveTo(point3.Position)

npc.Humanoid.MoveToFinished:Wait()

npc.Humanoid:MoveTo(point4.Position)

npc.Humanoid.MoveToFinished:Wait()

CreateDialogueEvent:FireAllClients(Max_Image,"This is our hotel guys.")

wait(5)

CreateDialogueEvent:FireAllClients(Max_Image,"Lets go inside")

wait(5)

npc.Humanoid:MoveTo(point5.Position)

npc.Humanoid.MoveToFinished:Wait()

npc.Humanoid:MoveTo(point6.Position)

npc.Humanoid.MoveToFinished:Wait()

wait(3)

GetWinEvent:FireAllClients()

CreateDialogueEvent:FireAllClients(Emma_Image,"Welcome to emma's hotel, how can I help you?")

wait(5)

CreateDialogueEvent:FireAllClients(Max_Image,"We want to check in. We reserved a room for so much people.")

wait(10)

CreateDialogueEvent:FireAllClients(Emma_Image,"One big room, okay sir, you have been checked in, I hope you enjoy your stay here, we will now clean your room.")

wait(14)

CreateDialogueEvent:FireAllClients(Max_Image,"Okay, thank you miss, okay guys, lets explore the city. come back when it will get dark.")

wait(15)

getRandomPlayer()

CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"Okay max, we promise we will come back before its dark.")

wait(5)

end

local function challenge_1_Night1()

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_Night1()

challenge_2_()

challenge_3_()

challenge_4_()

challenge_ending()

end

wait(10) -- waits 10 seconds

startGame() -- runs the startGame functionprint("Hello world!")
--Remote events
Local GetWinEvent = game.ReplicatedStorage.GetWinEvent

add this add the very top of the script.

--Our main npc

before local npc

--Points for npc

before local point1

This comments are made to avoid confusion when reading the code in the future.

Seems to work, but I have already a Stats.

Okay.
I will provide you a saving system for the wins incase you want.

Put this in your datastore script you just made earlier in serverscriptservice
--Put me before GetWinEvent
local function updateData(plr)
	local success, failed = pcall(function()
		dataStore:UpdateAsync(plr.UserId, function()
			local tbl = {}
			for _, i in pairs(plr.leaderstats:GetChildren()) do
				tbl[i.Name] = i.Value
			end
			return tbl
		end)
		print("Sucessfully saved in DataStore!")
	end)
	if failed then warn(failed); return end
end

game.Players.PlayerRemoving:Connect(function(plr)
	updateData(plr)
	print("Saving...")
end)

game:BindToClose(function()
	for _, i in pairs(game.Players:GetPlayers()) do
		updateData(i)
	end
end)

Please inform me if an error occurs from one of the codes I gave you.

Wait in the gamescript or somewhere else?

its self explanatory. Every script I gave lol

I am very confused, can you help me in the game itself

I wish I could but I’m working on a project. The Saving code is supposed to be pasted in the script you made in serverscriptservice. The local GetWin is for your main script. The Wins datastore I gave you is also for the script you made in serverscriptservice.

1 Like