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)
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)
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)
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?