My Issue Is when a variable in my code becomes true after being false the code dosent work it becomes true after a gui becomes disabled
Code
local Mouse = game.Players.LocalPlayer:GetMouse()
local db = false
local plr = game.Players.LocalPlayer
local Speed = 100
local Hold = false
local ts = game:GetService("TweenService")
local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local percentdone = 0
local OnThrow = game.ReplicatedStorage.OnThrow
local db = false
local db2 = false
local CanPlay = false
script.Parent.Parent.Parent:WaitForChild("TeamChoose"):GetPropertyChangedSignal("Enabled"):Connect(function()
CanPlay = not script.Parent.Parent.Parent:WaitForChild("TeamChoose").Enabled
print(CanPlay)
end)
Mouse.Button1Up:Connect(function()
if db == false and CanPlay then
db = true
script.sfx.Volume = percentdone/4
script.sfx:Play()
local Pos = Mouse.Hit
local target = Mouse.Target
local takedmg = 0
if target ~= nil and target.Parent:FindFirstChild("Humanoid") then
humanoid = target.Parent.Humanoid
local plrofhuman = humanoid:GetPlayerFromCharacter()
takedmg = percentdone
if plrofhuman.TeamColor == plr.TeamColor then
takedmg = 0
end
end
OnThrow:FireServer(Pos,Speed,takedmg,humanoid)
script.Parent.Visible = false
Hold = false
Speed = 100
script.Parent.Front.Size = UDim2.new(1,0,1,0)
percentdone = 0
wait(0.5)
db = false
end
end)
game:GetService("UserInputService").InputBegan:Connect(function(I,GPE)
if I.UserInputType == Enum.UserInputType.MouseButton1 and CanPlay then
script.Parent.Visible = true
Hold = true
end
end)
game["Run Service"].RenderStepped:Connect(function()
local camera = workspace.CurrentCamera
local worldPoint = plr.Character.Head.Position or plr.CharacterAdded:Wait().Head.Position
local vector, onScreen = camera:WorldToScreenPoint(worldPoint)
local mouse = game.Players.LocalPlayer:GetMouse()
local screenPoint = UDim2.fromScale(vector.X/mouse.ViewSizeX, vector.Y/mouse.ViewSizeY)
local depth = vector.Z
script.Parent.Position = screenPoint
script.Parent.Front:TweenSize(UDim2.new(1,0,1-percentdone/10,0),"Out","Sine",0.25)
end)
while true do
if Hold and Speed <= 1000 and percentdone > -0.01 and CanPlay then
Speed = Speed + 100
percentdone = percentdone + 1
end
wait(0.25)
end
What I want it to do is work after the gui gets disabled