Hello,
I set a GUI’s visibility to false in my script, but it’s not working. Here’s the script (note that this is a Local Script):
local trivago = script.Parent:WaitForChild("Trivago")
local TweenService = game:GetService("TweenService")
local chatmessage = game:GetService("Chat")
local USECOUNT = 0
local player = game:GetService("Players").LocalPlayer
player.Chatted:Connect(function(msg)
if msg == "hotel?" then
trivago.Visible = true
local tweenInfo = TweenInfo.new(
3,
Enum.EasingStyle.Quart,
Enum.EasingDirection.InOut,
-1,
true,
0
)
local tween = TweenService:Create(trivago,tweenInfo,{Rotation = trivago.Rotation + 250})
tween:Play()
end
if msg == "stop, i dont want a hotel!" and USECOUNT == 0 then
trivago.Visible = false
USECOUNT = USECOUNT + 1
game.StarterGui:SetCore("ChatMakeSystemMessage",{Text = "[System]: I saved you from that hotel.."})
if USECOUNT > 1 and msg == "stop!" then
trivago.Visible = false
game.StarterGui:SetCore("ChatMakeSystemMessage",{Text = "[System]: I saved you from that hotel.. again. Don't do it again... please. You've been doing this for " .. USECOUNT .. " times. LIKE STOP!"})
end
end
end)
I don’t know what to do; If you can help, please do! Thank you. (repost)
Based on the code you provided, it looks like the trivago.Visible property is being correctly set to false when the player chats the message “stop, i dont want a hotel!”. However, it’s possible that there are other parts of your code that are setting the visibility back to true after it has been set to false .
One potential issue is that the if condition if USECOUNT > 1 and msg == "stop!" will never be met, because the USECOUNT variable is only ever incremented by 1. This means that the code block inside this if statement will never be executed.
If you want to track how many times the player has used the “stop” command, you should increment the USECOUNT variable inside the if condition if msg == "stop, i dont want a hotel!" , like this:
if msg == "stop, i dont want a hotel!" then
trivago.Visible = false
USECOUNT = USECOUNT + 1
game.StarterGui:SetCore("ChatMakeSystemMessage",{Text = "[System]: I saved you from that hotel.."})
end
if USECOUNT > 0 and msg == "stop!" then
trivago.Visible = false
game.StarterGui:SetCore("ChatMakeSystemMessage",{Text = "[System]: I saved you from that hotel.. again. Don't do it again... please. You've been doing this for " .. USECOUNT .. " times. LIKE STOP!"})
end