server script(Inside Npc with button :
local rs = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local button = script.Parent.ProximityPrompt
local event = rs.Remotes:WaitForChild('RemoteDialogText')
local Quest = 60
local DialogsData = {
nic0 = {"Helo can you do something for me ? ", "I lost my sponge, can you fint this ?"," did you find my sponge? " },
nic0Answers = {No="No",Yes = "Okey",MaxStrony = 3, NextQuest ="NpcKIll",ThingsUneed ="Sponge",EndText =" thanks, you found my sponge",xp=80 }, -- just some data
NpcKIll0 = {"Test combat for me","get back to work"},
NpcKIll0Answers = {No="No",Yes = "Okey",MaxStrony = 1, NextQuest ="NpcKIll",ThingsUneed ="",NpcToKIll="Tester",NpcToKIllNum=1,EndText =" thanks",xp=200 }, -- just some data
text60 ="No DAta"
}
button.Triggered:Connect(function(Plr)
local player = players:FindFirstChild(Plr.Name)
local PLbacpack = Plr.Backpack
local idk = Plr.Character
local Quests = idk.QuestsStatus
local name = Quests:GetAttribute("Name")
local lvl = Quests:GetAttribute("Status")
print(name..lvl)
local Slowa = DialogsData[name..lvl]
local Answers = DialogsData[name..lvl.."Answers"]
event:FireClient(player,Answers ,Slowa,PLbacpack)
end)
local script(inside gui) :
local character = game:GetService("Players").LocalPlayer.Character
local label = script.Parent
local FlameDialog = label.Parent
local rs = game:GetService("ReplicatedStorage")
local eventNextQuest = rs.Remotes.RemoteEventNextQuest
local TextEvent = rs.Remotes.RemoteDialogText
local Butyes = label.Parent.TextButtonDIALOG_YES
local Butno = label.Parent.TextButtonDIALOG_NO
local strona = 1
local compete = false
TextEvent.OnClientEvent:Connect(function(odp, Slowa ,BackPack,Plr)
local Dialog = Slowa
label.Text = Dialog[strona]
Butyes.Text = odp["Yes"]
Butno.Text = odp["No"]
print(odp) print(Slowa)
Butyes.Activated:Connect(function()
if strona < odp["MaxStrony"] then
strona += 1
Butno.Visible=false
label.Text = Dialog[strona]
print("strona " ..strona)
end
if strona == odp["MaxStrony"] then
Butyes.Text = "yes"
Butno.Text = "no"
Butno.Visible = true
FlameDialog.Visible = false
compete =true
end
end)
if odp["ThingsUneed"] == nil then
print("ahdjkajksdhkashjd")
elseif BackPack:FindFirstChild(odp["ThingsUneed"]) or character:FindFirstChild(odp["ThingsUneed"]) and compete == true then
label.Text = odp["EndText"]
Butno.Visible = false
wait(1)
local item = BackPack:FindFirstChild(odp["ThingsUneed"]) or character:FindFirstChild(odp["ThingsUneed"])
item:Destroy()
local NextQuest = odp["NextQuest"]
eventNextQuest:FireServer(NextQuest)
local Leveling = character:FindFirstChild("Leveling")
local xp = Leveling:GetAttribute("xp")
Leveling:SetAttribute("xp",xp+odp["xp"])
print(xp+odp["xp"])
compete = false
end
--while true do
--wait(3)
--print("you neeed "..odp["ThingsUneed"]) -- to end quest
--end
end)
server script (Inside character Scripts) :
local event = rs.Remotes.RemoteEventNextQuest
local eventNpcKIllName = rs.Remotes.RemoteEventKIllNpcName
event.OnServerEvent:Connect(function(plr,NextQuest)
local Quest = NextQuest
script:SetAttribute("Name",Quest)
end)
eventNpcKIllName.OnServerEvent:Connect(function(plr,Model)
print("jkahdjkasjkda")
end)
--while true do
-- wait(3)
-- print(script:GetAttribute("Name").." lvl "..script:GetAttribute("Status"))
--end
Problem:
error inside local script :
Then the game start and I activate the button everything work great.(I pick up the sponge and click on npc)
But when I end first quest and the “RemoteDialogText” updates, then everything in “RemoteDialogText” changes to nil.