You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
making a capture zone like you would see in domination type cod games -
What is the issue? Include screenshots / videos if possible!
im using tweenservice to animate the capture progress but everytime the player leaves the zone it completes the tween -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
ive tried using tween:pause,cancel both will trigger the completed event which is what im using to detect when the zone is fully captured. ive tried checking the status of the tween with if statements but it just doesnt work im pretty bad at coding so would like to know what im missing here. maybe there is an easier way?
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!
local statusbar = script.Parent.CaptureGui.Frame.Status
local flag = script.Parent
local captureradius = script.Parent.Zone
local currentStatus = flag.CaptureGui.Frame.Status.Size.X.Offset
local isCaptured = false
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local garagelights = workspace.Bunkerenv.GarageLights
local container = flag
local zone = Zone.new(container)
local function OnCapture()
for i,v in ipairs(garagelights:GetChildren()) do
local light = v:FindFirstChild("PointLight")
if light then
v.BrickColor = BrickColor.new(176, 255, 250)
light.Color = Color3.fromRGB(176, 255, 250)
light.Brightness = 1.5
light.Range = 40
end
end
end
--`````~~~~~~~~~~~~~~~~~~~~~~~~~Gui Tween setup
local tweenService = game:GetService("TweenService")
local tweenInformation = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0)
local detweenInformation = TweenInfo.new(currentStatus +5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0)
local statusbarproperties = {
Size = UDim2.new(0,200,0,20)
}
local rewindstatusbarproperties = {
Size = UDim2.new(0,1,0,20)
}
local Tween = tweenService:Create(statusbar,tweenInformation,statusbarproperties)-- we use tweenservice to move the bar and detect when the animation finishes
local DeTween = tweenService:Create(statusbar,detweenInformation,rewindstatusbarproperties)
Tween.Completed:Connect(function()
if currentStatus > 199 then-- this seems to break the code, without it playerexited() will complete the tween
OnCapture()
end
end)
zone.playerEntered:Connect(function(player)
if isCaptured == false then
print(("%s entered the zone!"):format(player.Name))
Tween:Play()
DeTween:Pause()
end
end)
zone.playerExited:Connect(function(player)
print(("%s exited the zone!"):format(player.Name))
if currentStatus < 200 then-- this doesnt seem to do anything
Tween:Pause()
DeTween:Play()
end
end)
