so i was making a client toggle, to toggle player collisions
most of the local script is the toggle animation but the MakePlayerCollideable() is the method which for some reason enables collisions again after a while…
local Toggle = script.Parent
local Cirkel = Toggle.Cirkel
local BG = Toggle.BackGround
local TweenService = game:GetService("TweenService")
local Tweeninfo = TweenInfo.new(0.5,Enum.EasingStyle.Back,Enum.EasingDirection.Out,0,false,0)
local Colorinfo = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local Debounce = false
local Toggled = false
local function MakePlayerCollidable(Collision : boolean)
for I,Player in pairs(game.Players:GetPlayers()) do
for i,v in pairs(Player.Character:GetChildren()) do
if v:IsA("MeshPart") or v:IsA("Part") then
v.CanCollide = Collision
end
end
end
end
Cirkel.Activated:Connect(function(obj,clicks)
if Debounce then return end
Debounce = true
if Toggled then
Toggled = false
local Disable = TweenService:Create(Cirkel,Tweeninfo,{Position = UDim2.new(0.115, 0,0.164, 0)})
local Colored = TweenService:Create(BG,Colorinfo,{BackgroundColor3 = Color3.fromRGB(255, 120, 102)})
Colored:Play()
Disable:Play()
else
Toggled = true
local Enable = TweenService:Create(Cirkel,Tweeninfo,{Position = UDim2.new(0.538, 0,0.164, 0)})
local Colored = TweenService:Create(BG,Colorinfo,{BackgroundColor3 = Color3.fromRGB(85, 255, 127)})
Enable:Play()
Colored:Play()
end
MakePlayerCollidable(Toggled)
task.wait(1)
Debounce = false
end)
do you have any idea?
Thanks in advance!