I’m trying to make a medkit script that heals… the user maybe?
This local script here is in the tool, it captures the player’s mouse, listen for key press events and fire remotes to a serverside to heal the user. But, the wait’s in this script just stops it. Here is a section of the code I’m having isuues with:
local function halt(a)
if db then print'debounce' else
db = true
if a == "cancel" then print("cancelled")
playing = false
cam.CameraSubject = char.Humanoid
cam.CameraType = Enum.CameraType.Custom
cam.CFrame = char.Head.CFrame
plr.PlayerGui.headsupdisplay.weapons.charge.bar.Visible = false
plr.PlayerGui.headsupdisplay.weapons.charge.Visible = false
plr.PlayerGui.headsupdisplay.weapons.charge.bar.Position = UDim2.new(0.02, 0, 0.182, 0)
plr.PlayerGui.headsupdisplay.weapons.charge.bar.Size = UDim2.new(0,0,0,7)
db = false
else print("not cancelled, nice.")
plr.PlayerGui.headsupdisplay.helth.Visible = true
script.Parent.RemoteEvent:FireServer()
playing = false
cam.CameraSubject = char.Humanoid
cam.CameraType = Enum.CameraType.Custom
cam.CFrame = char.Head.CFrame
plr.PlayerGui.headsupdisplay.weapons.charge.bar.Visible = false
plr.PlayerGui.headsupdisplay.weapons.charge.Visible = false
plr.PlayerGui.headsupdisplay.weapons.charge.bar.Position = UDim2.new(0.02, 0, 0.182, 0)
plr.PlayerGui.headsupdisplay.weapons.charge.bar.Size = UDim2.new(0,0,0,7)
ts:Create(plr.PlayerGui.headsupdisplay.helth.move, TweenInfo.new(30, Enum.EasingStyle.Linear), {--[[Position = UDim2.new(0.05, 0, 0.04, 0),]] Size = UDim2.new(0.913, 0, 0, 0)}):Play()
print("a")
wait(30)
print("aa")
ts:Create(plr.PlayerGui.headsupdisplay.helth, TweenInfo.new(2), {BackgroundTransparency = 1}):Play()
ts:Create(plr.PlayerGui.headsupdisplay.helth.move, TweenInfo.new(2), {BackgroundTransparency = 1}):Play()
ts:Create(plr.PlayerGui.headsupdisplay.helth.ImageLabel, TweenInfo.new(2), {ImageTransparency = 1}):Play()
print("aaa")
wait(2)
print("aaaa")
plr.PlayerGui.headsupdisplay.helth.Visible = false
end
db = false
end
end
(sorry, it is a spagetti, i know)
Yes, the first tween(ts:Create(plr.PlayerGui.headsupdisplay.helth.move, TweenInfo.new(30, Enum.EasingStyle.Linear), {Size = UDim2.new(0.913, 0, 0, 0)}):Play()
) works. The event fires too. Everything except below the wait(30)
works.
I also tried tween.Completed:Wait()
, it also stops the script.
After waiting for 30 seconds(and more), the output only shows “a” as an output. The others never show up. Any help for this? Thanks in advance.