i was coding a quest system and implementing some values so that i dont have to make so many scripts for each quest, only problem, is that everytime i try to take the value of both collected and limit value, it doesnt take it probably only leaving it on 0/0
local player = game:GetService("Players").LocalPlayer
local questactive = script.Parent.Parent.Parent.QuestActive.Value
local questcomplete = script.Parent.Parent.Parent.QuestComplete.Value
local limit = script.Parent.Parent.Parent.Limit.Value
rep.RemoteEvents.MafiaMouse.OnClientEvent:Connect(function(plr)
if questactive == false then
questactive = true
limit = 5
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = fake.CFrame
player.Character.Humanoid.WalkSpeed = 0
camera.CFrame = fake.CFrame
script.Parent.Visible = true
script.Parent.Character.Text = "Mafia Mouse"
script.Parent.Text.Text = "Seems your new here..."
wait(4)
script.Parent.Text.Text = "Go and get 5 trash bag and then come back to me"
wait(4)
player.Character.Humanoid.WalkSpeed = 16
camera.CameraType = Enum.CameraType.Custom
print("Quest started")
script.Parent.Visible = false
script.Parent.Parent.QuestFrame.Visible = true
script.Parent.Parent.QuestFrame.Quest.Text = "Collect 5 trash bags"
heres the other script which takes all the values and puts it in text
local collected = script.Parent.Parent.Parent.Collected
local rep = game.ReplicatedStorage
local limit = script.Parent.Parent.Parent.Limit
local questactive = script.Parent.Parent.Parent.QuestActive
local questcomplete = script.Parent.Parent.Parent.QuestComplete
rep.RemoteEvents.Trash.OnClientEvent:Connect(function()
print("got event")
if questactive.Value == true then
collected.Value = collected.Value + 1
script.Parent.Counter.Text = tostring(collected.Value).."/"..tostring(limit.Value)
end
end)
if questactive.Value == true then
script.Parent.Counter.Text = tostring(collected.Value).."/"..tostring(limit.Value)
while task.wait() do
if collected.Value == limit.Value then
questcomplete = true
print("Quest completed")
break
end
end
end
if theres any help, i would apprecheate it
5 Likes
also just to claryfiy, both scripts are local and are using values to transmit information to each other
1 Like
I’m not sure, but it seems like the tostring()
method is having trouble converting numbers to strings. And there is no need to convert Value to a string. This is because Luau
does the conversion for you.
2 Likes
no i mean like, what it was suppost to do is grab the collected and limit data from the value and put it in text, it doesnt work for some reason
1 Like
So, if you print collected.Value
, does it print correctly?
2 Likes
i did print the limit value and it works perfectly fine, only the collect value isnt printing, or firing the event
local prox = script.Parent
prox.Triggered:Connect(function(plr)
game.ReplicatedStorage.RemoteEvents.Trash:FireClient(plr)
script.Parent.Parent:Destroy()
end)
1 Like
Let me show you a video, its hard to explain
2 Likes
You mean, the text is always stuck in 0/0 although you collect objects? If then, does collected.Value
display alright in Explorer?
1 Like
nope it isnt displaying right, also all of the values are in screen gui
1 Like
it was suppost to go like this
-
if the player collects trash, the trash will fire an event and destory its self
-
the local script will catch the remote event and plus the collect value with 1 before updating it to the text
2 Likes
also the trash uses proximity prom
Could you check whether the signal has properly received by printing it in the OnClientEvent()
part of LocalScript?
yes the remote event works fine, i still dont understand the problem, heres some images


also, for some reason im not getting any error from the scripts
heres full script if you need
local rep = game.ReplicatedStorage
local current = workspace.CurrentCamera
local fake = workspace.MafiaMouseCam
local camera = workspace.Camera
local player = game:GetService("Players").LocalPlayer
local questactive = script.Parent.Parent.QuestActive.Value
local questcomplete = script.Parent.Parent.QuestComplete.Value
local limit = script.Parent.Parent.Limit.Value
rep.RemoteEvents.MafiaMouse.OnClientEvent:Connect(function(plr)
if questactive == false then
questactive = true
limit = 5
print(limit)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = fake.CFrame
player.Character.Humanoid.WalkSpeed = 0
camera.CFrame = fake.CFrame
script.Parent.Visible = true
script.Parent.Character.Text = "Mafia Mouse"
script.Parent.Text.Text = "Seems your new here..."
wait(4)
script.Parent.Text.Text = "Go and get 5 trash bag and then come back to me"
wait(4)
player.Character.Humanoid.WalkSpeed = 16
camera.CameraType = Enum.CameraType.Custom
print("Quest started")
script.Parent.Visible = false
script.Parent.Parent.QuestFrame.Visible = true
script.Parent.Parent.QuestFrame.Quest.Text = "Collect 5 trash bags"
else
if questcomplete == true then
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = fake.CFrame
player.Character.Humanoid.WalkSpeed = 0
camera.CFrame = fake.CFrame
script.Parent.Visible = true
script.Parent.Character.Text = "Mafia Mouse"
script.Parent.Text.Text = "alright.. seems your ready for the mission"
elseif questactive == true then
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = fake.CFrame
player.Character.Humanoid.WalkSpeed = 0
camera.CFrame = fake.CFrame
script.Parent.Visible = true
script.Parent.Character.Text = "Mafia Mouse"
script.Parent.Text.Text = "Have you collected all the trash bags?"
wait(4)
player.Character.Humanoid.WalkSpeed = 16
camera.CameraType = Enum.CameraType.Custom
script.Parent.Visible = false
end
end
end)
1 Like
Sorry, but I didn’t mean that part, I meant, Trash RemoteEvent part.
local prox = script.Parent
prox.Triggered:Connect(function(plr)
game.ReplicatedStorage.RemoteEvents.Trash:FireClient(plr)
script.Parent.Parent:Destroy()
end)
LocalScript? (where get the Trash RemoteEvent signal)
yes local script, it fires and the local script catches it
1 Like