hello, i need help with this script that I have made that is not working right. Here’s the script.
local player = game.Players.LocalPlayer
local playerG = player.PlayerGui
local cold = game.Workspace.effection.cold
local radiation = playerG["radiation system"].Frame.Frame
local volume = 1000
local humanoid = player.Character:WaitForChild("Humanoid")
local effect = false
volume = math.clamp(volume, 0, 1000)
-- setting cold system
task.wait(1.02)
cold.Touched:Connect(function()
effect = true
while volume > 0 and effect do
script.Parent.Parent.Parent.Enabled = true -- the gui will appear
volume = volume - 1
script.Parent.BackgroundColor3 = Color3.new(0.521569, 0.690196, 0.709804)
-- resize for the volume
script.Parent:TweenSize(UDim2.new(volume/126, 0, 0.7, 0), 'Out', 'Linear', 0)
wait()
if volume == 0 then -- will repeat until the player is not touching the part
repeat
humanoid.Health = humanoid.Health -1
task.wait(2.55)
until
game.Workspace.Baseplate.Touched:Connect(function(off)
if off.Parent:WaitForChild("Humanoid") then
effect = false
print("stop frezze")
while volume > 0 and not effect do
volume = volume +1
-- resize back to the full volume
script.Parent:TweenSize(UDim2.new(volume/126, 0, 0.7, 0), 'Out', 'Linear', 0)
wait()
if volume ~= 1000 then -- close the gui, when reach amount to full volume
task.wait()
print("enabled gui")
script.Parent.Parent.Parent.Enabled = false -- close gui
end
end
end
end)
end
end
end)
the issue is when you touch the part/cold the gui is not in the right size place correctly and if the player touch baseplate or untouched the part the gui will flicker a lot and stop and when move while touching the baseplate the script signal repeat a lot of time until you stop.if you can help me with this problem,
I gradually appreciate i