Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Questing System - GUI Won't load, why?

Asked by 2 months ago
Edited 2 months ago

Hello all, I am creating a questing system, and the GUI Will NOT load after line 87-89 happens and I have no clue as to why! I will post the whole script here, to see if it's an issue with anything else. Everything is in the correct places according to the code, and everything lines up properly, so as to why it doesn't work is beyond me! Any and all help is appreciated! Thanks Code:

repeat wait() until game.Players.LocalPlayer

--Rewards------------------------------------------------------------------------------------------

local Gold = true --True/False

local GoldReward = 50 --Number

local Experience = false --True/False

local ExperienceReward = 100 --Number

local Weapon = " " --Weapon Name

local BadgeID = 0 --Badge ID

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

function Reward(plyr)

if Gold then

plyr.leaderstats.Gold.Value = plyr.leaderstats.Gold.Value + GoldReward

end

if Experience then

plyr.leaderstats.XP.Value = plyr.leaderstats.XP.Value + ExperienceReward

end

if Weapon ~= " " then

game.ReplicatedStorage[Weapon]:clone().Parent = plyr.Backpack

game.ReplicatedStorage[Weapon]:clone().Parent = plyr.StarterGear

end

game:GetService("BadgeService"):AwardBadge(plyr.userId, BadgeID)

end

--Settings---------------------------------------------------------------------------------------------

QuestName = "Quest1" --Name of QuestGui

local Monster = "InfectedSoldier"

local Kills = 10

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

local a = 1

local TextFrame = script.Parent:WaitForChild("Talk")

local Dialog = script.Parent:WaitForChild("TextButton")

local Dialog2 = script.Parent:WaitForChild("TextButton2")

local Player = game.Players.LocalPlayer

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

script.Parent.TextButton.MouseButton1Click:connect(function()

if not Player:FindFirstChild(Monster) then

if a == 1 then a = 2

TextFrame.Text = "Hey! Can you help me?" --NPC

Dialog.Text = "What do you need help with?" -- You

elseif a == 2 then a = 3

TextFrame.Text = "Those terrible Military Soldiers killed my family. Slay them..." --NPC

Dialog.Text = "For sure!" -- You

Dialog2.Text = "No. I'm not ready"

elseif a == 3 then a = 4

TextFrame.Text = "Thank you, avenge them! I will give you 50 Gold!" --NPC

Dialog.Text = "Awesome! I will!" -- You

Dialog2:Destroy()

elseif a == 4 then

local c = Instance.new("IntValue", Player)

c.Name = Monster

c.Value = 0

local z = game.ServerStorage.Quest1:clone()

z.Parent = Player:FindFirstChild("PlayerGui")

script.Parent.Parent:Destroy()

end

elseif Player:FindFirstChild(Monster) then

if Player[Monster].Value < Kills then

if a == 1 then a =2

TextFrame.Text = "You need to kill more!" --What happens if you didn't kill enough

Dialog.Text = "Ok!"

Dialog2:Destroy()

elseif a == 2 then

script.Parent.Parent:Destroy()

end

elseif Player[Monster].Value >= Kills then

if a == 1 then a = 2

TextFrame.Text = "Thank you! Here is your Gold!!" --When you finish the quest

Dialog.Text = "You're welcome! They will rest well."

Dialog2:Destroy()

if Player.PlayerGui:FindFirstChild(QuestName) then

Player.PlayerGui[QuestName]:Destroy()

end

elseif a == 2 then

Player[Monster]:Destroy()

script.Parent.Parent:Destroy()

Reward(Player)

end

end

end

end)



script.Parent.TextButton2.MouseButton1Click:connect(function()

script.Parent.Parent:destroy()

end)
0
Interesting "Those terrible Military Soldiers killed my family. Slay them..." ok i did not take much attention to the code but i think you used an number on some of those instances like `Dialog2`, pretty sure you have gotta do like ["Dialog2"].Text = "blahblah" Igoralexeymarengobr 243 — 2mo
0
That isn't the issue. As the dialog lines up. The issue is the next gui after the quest is given doesn't appear, and no idea why. No output errors. BryanFehr 86 — 2mo

1 answer

Log in to vote
0
Answered by
VicyX 5
2 months ago
Edited 2 months ago

I think the problem lies here:

repeat  wait() until game.Players.LocalPlayer

This should be:

repeat
    wait()
    --Code
until game.Players.LocalPlayer

Refer to https://developer.roblox.com/articles/Roblox-Coding-Basics-Loops#repeat

0
Would it having no value inside the () make the script fail to work? BryanFehr 86 — 2mo
0
Or is it possibly in the code where it calls local player? BryanFehr 86 — 2mo
0
Tried that, that isn't the issue BryanFehr 86 — 2mo
0
Im not sure what you are trying to get at with the until game.Players.LocalPlayer portion. What do you want to stop the script? VicyX 5 — 2mo
0
Nothing. So, when I step on the brick the GUI pops up, and you can "talk" to the guy supposedly giving you the quest, but once you're done, and you press the last button, the GUI stays, and doesn't "give" you the quest. No idea as to why. BryanFehr 86 — 2mo
Ad

Answer this question