local RS = game:GetService("ReplicatedStorage")
local Event = RS.HotPotatoSelected
local Start = RS.PotatoCreateEvent
local Potato = Instance.new("Accessory")
RS.Handle.Parent = Potato
local Attatchment = Instance.new("Attachment")
Attatchment.Name = "BodyFrontAttachment"
Attatchment.Parent = Potato.Handle
Potato.Parent = RS
Potato.Name = "Potato"
Attatchment.Orientation = Vector3.new(0,0,-90)
print("Potato Instance has been created")
Event.OnServerEvent:Connect(function()
local Players = game.Players:GetPlayers()
local random = Players[math.random(1,#Players)]
Start.OnServerEvent:Connect(function()
local PotatoClone = Potato:Clone()
PotatoClone.Parent = random.Character
print("Potato Instance has been attached to the player")
local cooldown = true
PotatoClone.Handle.Touched:Connect(function(hit)
if hit.Name == "HumanoidRootPart" then
if cooldown then
cooldown = false
PotatoClone.Parent = hit.Parent
print("Swapped Potato to",hit.Parent)
wait(2)
warn("cooldown done")
cooldown = true
end
end
end)
end)
end)
This script is for a hot potato game. It will make a potato then put it on a random player, then whoever is the potato can pass it on to another player by touching them.
I’m trying to make it so that in another script, a while loop runs. This loop will count down the time until the potato blows up. Is there a way to reference the potato in that script without knowing where exactly it is?