Anti-Exploitable "One-way Platforms"

This script is for these one-way platforms, akin to ones in platform-fighting games, I made that players can individually go through but I need a way to prevent exploiters from tampering with this while still achieving something like this. The thing is that I want each individual player to go through the platform part without disabling the collision for the other player.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local platformsParent = workspace.Workspace.Platforms

local openParts = {}
local closeParts = {}
local platformParts = {}

for _, platform in ipairs(platformsParent:GetChildren()) do
    table.insert(openParts, platform:WaitForChild("Open"))
    table.insert(closeParts, platform:WaitForChild("Close"))
    table.insert(platformParts, platform:WaitForChild("Platform"))
end

local function checkPlayerInsidePlatform()
    while task.wait(0.1) do

        for i = 1, #openParts do
            local open = openParts[i]
            local close = closeParts[i]
            local platform = platformParts[i]

            local partsInOpen = workspace:GetPartsInPart(open)
            local partsInClose = workspace:GetPartsInPart(close)

            local playerInside = false

            for _, part in ipairs(partsInOpen) do
                if part:IsDescendantOf(character) then
                    platform.CanCollide = false
                    playerInside = true
                    break
                end
            end

            if not playerInside then
                for _, part in ipairs(partsInClose) do
                    if part:IsDescendantOf(character) then
                        task.wait(0.25)
                        platform.CanCollide = true
                        playerInside = true
                        break
                    end
                end
            end
        end
    end
end

task.spawn(checkPlayerInsidePlatform)

You could read the whole post first before replying? He wants help with making the script unable to be exploited. OP should move this to #help-and-feedback:scripting-support

Ohhhh, on first read it sounded like they were giving it away, mb yalls

1 Like

Sorry about that Ill do that rn