Hi, my script isn’t working but it’s not giving any errors or red lines. Here’s the code:
local TutorialGui = script.Parent
local TutorialFrame = TutorialGui:WaitForChild("TutorialFrame")
local YesButton = TutorialFrame:WaitForChild("Yes")
local NoButton = TutorialFrame:WaitForChild("No")
local AmountOfPlayerVisits = 1
TutorialGui.Enabled = false
player.CharacterAdded:Connect(function()
AmountOfPlayerVisits += 1
if AmountOfPlayerVisits == 1 then
TutorialGui.Enabled = true
TutorialFrame.Text = "Hey there! It looks like you are new, would you like a tutorial?"
YesButton.MouseButton1Click:Connect(function()
TutorialFrame.Text = "Continue Tutorial..."
NoButton.MouseButton1Click:Connect(function()
TutorialFrame.Text = "Ok, enjoy your stay! (If you ever want to go back to the tutorial, (insert thing here)"
end)
end)
end
end)
The Gui just doesn’t show, does anyone know what’s happening?
--//Services
local Players = game:GetService("Players")
--//Variables
local LocalPlayer = Players.LocalPlayer
local TutorialGui = script.Parent
TutorialGui.Enabled = false
local TutorialFrame = TutorialGui:WaitForChild("TutorialFrame")
local YesButton = TutorialFrame:WaitForChild("Yes")
local NoButton = TutorialFrame:WaitForChild("No")
--//Controls
local AmountOfPlayerVisits = 0
--//Functions
LocalPlayer.CharacterAdded:Connect(function()
AmountOfPlayerVisits += 1
if AmountOfPlayerVisits == 1 then
TutorialGui.Enabled = true
TutorialFrame.Text = "Hey there! It looks like you are new, would you like a tutorial?"
YesButton.MouseButton1Click:Connect(function()
TutorialFrame.Text = "Continue Tutorial..."
NoButton.MouseButton1Click:Connect(function()
TutorialFrame.Text = "Ok, enjoy your stay! (If you ever want to go back to the tutorial, (insert thing here)"
end)
end)
end
end)
Maybe because the code is running after the player’s character is added? Try checking by respawning your character.
If so just edit the code to check if a character already exists (if Player.Character and Player.Character:IsDescendantOf(workspace), if not wait for the player’s character to be added
edit: nevermind, it could be that but it’s also because the variable “AmountOfPlayerVisits” is set to 1 when it is supposed to be 0