For a game I am making, Im scripting a fountain machine, and started off with the water in it.
The entire script works. But, it will only work once, the fountain machine wont work a second time. I don’t know if I have to add a loop or if there is just something wrong with the code.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Tried different cloning methods and got rid of :Destroy() at the end for something in ReplicatedStorage, it didn’t work.
local Water = script.Parent
local WaterTouch = Water.DasaniTouchPart
local debounce = false
local lever = Water.NotMovedPart
local MovedPart = Water.MovedPart
WaterTouch.Touched:Connect(function(PlayerThatTouched)
if not debounce then
debounce = true
wait(.33)
lever.Transparency = 1
MovedPart.Transparency = 0
local FakeCup = Water.WaterCup
FakeCup.Transparency = 0
local RealCup = PlayerThatTouched.Parent
local Character = RealCup.Parent
if RealCup.Name == "Empty Cup" then
RealCup.Parent = game.Lighting
wait(3)
FakeCup.Transparency = 1
lever.Transparency = 0
MovedPart.Transparency = 1
local RealWater = game.ReplicatedStorage.RealWater
local RealWaterClone = RealWater:Clone()
RealWaterClone.Parent = Character
RealWaterClone.Name = "Water"
else
print("Already have a liquid")
end
end
end)
Should I add a loop, or is there something wrong with the code that I need to fix? Thanks for reading.