Hello! My GUI is going back to Intermission when I touch the special lemon. Can you please help me?
Script:
game.Workspace.Fruit.SpecialLemon.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local status = game.ReplicatedStorage:WaitForChild("Status")
while true do
wait(1)
status.Value = "Intermission"
wait(10)
status.Value = "Game in progress, you have one minute"
wait(60)
status.Value = "Game is over!"
wait(1)
status.Value = "The winner is"..player.Name"!"
end
end)
Judging by the script, you want it to go into intermission after you touch the lemon? what exactly is the problem…? if it’s the fact that it keeps repeating, just remove the while true do.
No I want it to go to still wait for the time to end and the status to say the game is over and who the winner is, then repeat the script from the intermission.
try moving the while true do after the touched function and have the player variable update after it is touched like this:
local player = nil
game.Workspace.Fruit.SpecialLemon.Touched:Connect(function(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent)
end)
local status = game.ReplicatedStorage:WaitForChild("Status")
while true do
wait(1)
status.Value = "Intermission"
wait(10)
status.Value = "Game in progress, you have one minute"
wait(60)
status.Value = "Game is over!"
wait(1)
if player ~= nil then --added this to prevent errors.
status.Value = "The winner is"..player.Name"!"
end
end
that would be because nobody touched the lemon. Here’s a script where it will tell if there is a winner and if there isn’t:
local player = nil
game.Workspace.Fruit.SpecialLemon.Touched:Connect(function(hit)
if not hit.Parent:FindFirstChild("Humanoid") then --another check so there are no errors.
return
end
player = game.Players:GetPlayerFromCharacter(hit.Parent)
end)
local status = game.ReplicatedStorage:WaitForChild("Status")
while true do
wait(1)
status.Value = "Intermission"
wait(10)
status.Value = "Game in progress, you have one minute"
wait(60)
status.Value = "Game is over!"
wait(1)
if player ~= nil then --added this to prevent errors.
status.Value = "The winner is"..player.Name.."!"
else
status.Value = "There is no winner!"
end
end