Help me with local script (Value, Event)

When I get to 300 TimePlayed Value the gui dont change automatic

local RS = game:GetService("ReplicatedStorage")
local Plrs = game:GetService("Players")

local RE = RS:WaitForChild("TimeQuesrt")
local Plr = Plrs.LocalPlayer
local Pat = Plr:WaitForChild("TimePlayed").Value

--RE.Touched:Connect(function(Hit)
	--local Target = Hit.Parent
	local value = Pat >= 300
	--local TouchedPlr = Plrs:GetPlayerFromCharacter(Target)

	if value then
		RE:FireServer() -- This will send a request from the client to the server 
	end
--	end)

inside StarterPlayerScripts local script

local RS = game:GetService("ReplicatedStorage")
local RE = RS:WaitForChild("TimeQuesrt")

RE.OnServerEvent:Connect(function(Plr)
	local gui1 = Plr.PlayerGui.HalloweenEventQuest.FrameQuest2["step 2"]
	
	local gui2 = Plr.PlayerGui.HalloweenEventQuest.FrameQuest2.nextQust2
	
	gui1.Text = "Second Step Done!"
	
		gui2.Visible = true

	end)

script inside ServerScriptService
thx to Corruptux too

First, you can’t change a player’s GUI locally in a server script!
Also, you shouldn’t check for a player’s value in a local script if you need the server for it.
Use this as a server script in ServerScriptService:

local RS = game:GetService("ReplicatedStorage")
local Plrs = game:GetService("Players")

local RE = RS:WaitForChild("TimeQuesrt")
YOURPART.Touched:Connect(function(Hit)
	local TouchedPlr = Plrs:GetPlayerFromCharacter(Target)
    local value = TouchedPlr:WaitForChild("TimePlayed").Value
	if value >= 300 then
       --Your event firing here (make sure to use FireClient(TouchedPlr))
	end
end)

Then use this as a local script. Don’t put it in StarterPlayerScripts!

YOUREVENT.OnClientEvent:Connect(function()
	local gui1 = game.Players.LocalPlayer.PlayerGui.HalloweenEventQuest.FrameQuest2["step 2"]
	local gui2 = game.Players.LocalPlayer.PlayerGui.HalloweenEventQuest.FrameQuest2.nextQust2
	gui1.Text = "Second Step Done!"
	gui2.Visible = true
end)

do I need to use part for that?

You’re using the TouchedEvent so yes replace YOURPART with your part!

Also in YOUREVENT just put the location of the event you fired!

there is no rly location of the event its gui but fine.
yea im using remote event.

You’re using a RemoteEvent, right?

If so, make sure to put it somewhere else, like ReplicatedStorage.

the remote event already there, i wanna make it automatic not when you touch a part
im trying to use MouseButton1Down

local script?

then you can just use a single local script:

local Player = game.Players.LocalPlayer
local Pat = Player:WaitForChild("TimePlayed").Value
Pat:GetPropertyChangedSignal("Value"):Connect(function()
    if Pat < 300 then return end
   	local gui1 = Player.PlayerGui.HalloweenEventQuest.FrameQuest2["step 2"]
	local gui2 = Player.PlayerGui.HalloweenEventQuest.FrameQuest2.nextQust2
	gui1.Text = "Second Step Done!"
	gui2.Visible = true
end)

Is that what you mean?

So you’re trying to check if the value is higher or equal to 300 every time you press the GUI button (MouseButton1Down)?
If so, just do this:

local Player = game.Players.LocalPlayer
local Pat = Player:WaitForChild("TimePlayed").Value
YOURBUTTON.MouseButton1Down:Connect(function()
   	local gui1 = game.Players.LocalPlayer.PlayerGui.HalloweenEventQuest.FrameQuest2["step 2"]
	local gui2 = game.Players.LocalPlayer.PlayerGui.HalloweenEventQuest.FrameQuest2.nextQust2
	gui1.Text = "Second Step Done!"
	gui2.Visible = true
end)

hmm just listen Im doing quest that if you have 300 timeplayed or more some button like you see will show, and save if you atleast reset

This script just activates the function whenever the value is changed then if it’s lower than 300 it will end instead of showing the GUI!

Also if you want it to save when resetting, go to your ScreenGui object and set ResetOnSpawn to false!

yeah im checking it right now.

Also quick thing change game.Players.LocalPlayer in local gui1 and local gui2 to Player.

1 Like


dont work the nextquest button not showing up

is gui1 supposed to be visible or is it supposed to go visible when the value is 300?
Also is gui1 the button?

the gui1 is button and only the button and the text need to change
nvm the gui1 is a text
and gui2 is a button

the script i said there is problem with it worked well but the one problem was its wasn’t automatic
(the script inside the topic)
you sure there is no way to fix it?

check for any errors!
I found something that might be a spelling error:

	local gui2 = game.Players.LocalPlayer.PlayerGui.HalloweenEventQuest.FrameQuest2.nextQuest2

you typed nextQust2, is it supposed to be nextQuest2?

yea its nextQust2
im change lazy to chang it back

yea i know lol im checking it
(the output)

Check for any errors in the Output Window.
To open it, go to the view tab and find the Output button!