I had a script, but for some reason when i play it doesn’t print even thought it’s on loop, however when i check it on server it starts running.
video example:
the loop:
coroutine.resume(coroutine.create(function()
while wait(0) do
print("ez")
bindables.Edge_Screen:Fire(workspace.Dummy.HumanoidRootPart, char.HumanoidRootPart)
--game_module:CheckOutOfBounds(workspace.Dummy.HumanoidRootPart, char.HumanoidRootPart)
end
end))
the script:
local index = true do
MAX_DISTANCE = 5
end
local isOutOfBounds = workspace.Map.Bounds
local opponentRoot = nil
local opponent_Sides = 3
local playerRoot = nil
local player_Sides = isOutOfBounds.Sides
local function Static(boundary, pos1, pos2)
boundary:SetPrimaryPartCFrame(CFrame.new(Vector3.new(
pos1.Position.X + pos2.Position.X/5,
boundary.PrimaryPart.Position.Y,
boundary.PrimaryPart.Position.Z
)
)
)
end
local function CreateDistanceFromVector(vector, rightVector, leftVector)
local distances = {
left = (vector - leftVector).Magnitude;
right = (vector - rightVector).Magnitude
}
return distances
end
local function CheckDistance(distance)
-- MAX_DISTANCE in this case is 100 pixels
-- distance arguement is the table created from CreateDistanceFromVector()
if (distance.left <= MAX_DISTANCE) or (distance.right <= MAX_DISTANCE) then
return true
end
return false
end
function GetEntityDistanceFromCamera(root)
local cameraToRootVector = workspace.Camera:WorldToScreenPoint(root.Position)
local rightVector = Vector2.new(workspace.Camera.ViewportSize.X, 0)
local leftVector = Vector2.new()
local newVector = Vector2.new(math.clamp(cameraToRootVector.X, 0, rightVector.X), 0)
local distances = CreateDistanceFromVector(newVector, rightVector, leftVector)
return distances
end
function CheckOutOfBounds(OpponentRoot, PlayerRoot)
--print("BRUH")
local OPPONENT_OUT_OF_BOUNDS = CheckDistance(GetEntityDistanceFromCamera(OpponentRoot))
local PLAYER_OUT_OF_BOUNDS = CheckDistance(GetEntityDistanceFromCamera(PlayerRoot))
local P_Humanoid = PlayerRoot.Parent.Humanoid
local O_Humanoid = OpponentRoot.Parent.Humanoid
opponentRoot = OpponentRoot
playerRoot = PlayerRoot
if (PLAYER_OUT_OF_BOUNDS and OPPONENT_OUT_OF_BOUNDS) then
--print("BOTH ARE OUT OF BOUNDS")
isOutOfBounds.Value = true
elseif PLAYER_OUT_OF_BOUNDS then
print("PLAYER1 IS OUT OF BOUNDS")
isOutOfBounds.Value = true
elseif OPPONENT_OUT_OF_BOUNDS then
print("PLAYER2 IS OUT OF BOUNDS")
isOutOfBounds.Value = true
--[[
if P_Humanoid.MoveDirection == Vector3.new(1,0,0) then
print("E")
player_Sides.Value=5
elseif P_Humanoid.MoveDirection == Vector3.new(-1,0,0) then
print("A")
player_Sides.Value=-5
end
--]]
else
if P_Humanoid.MoveDirection ~= Vector3.new(0,0,0)
and (PlayerRoot.Position - OpponentRoot.Position).magnitude < 4
then
print("player is walking")
Static(workspace.Boundaries, playerRoot, opponentRoot)
elseif O_Humanoid.MoveDirection ~= Vector3.new(0,0,0)
and (OpponentRoot - PlayerRoot.Position).magnitude < 4
then
print("opponent is walking")
Static(workspace.Boundaries, OpponentRoot, playerRoot)
elseif O_Humanoid.MoveDirection ~= Vector3.new(0,0,0) and P_Humanoid.MoveDirection ~= Vector3.new(0,0,0)
and (PlayerRoot.Position - OpponentRoot.Position).magnitude < 6
then
print("both are walking")
Static(workspace.Boundaries, playerRoot, opponentRoot)
else
print("NO")
end
--Static(workspace.Static_Left, workspace.Static_Right, false, PlayerRoot, OpponentRoot, -3, 3)
--print("NONE ARE OUT OF BOUNDS")
isOutOfBounds.Value = false
end
end
isOutOfBounds.Changed:Connect(function(old)
if isOutOfBounds.Value == true
--and isOutOfBounds.Value ~= old
then
--Static(workspace.Boundaries, playerRoot, opponentRoot)
--[[
Static(workspace.Static_Left,
workspace.Static_Right,
true, playerRoot,
opponentRoot,
-player_Sides.Value,
player_Sides.Value,
playerRoot, true, opponentRoot
)
--]]
else
--Static(workspace.Boundaries, playerRoot, opponentRoot)
end
end)
player_Sides.Changed:Connect(function()
if player_Sides.Value == -5 then
--Static(workspace.Boundaries, playerRoot, opponentRoot)
--[[
Static(workspace.Static_Left, workspace.Static_Right,
true, playerRoot, opponentRoot, 5, 5,
opponentRoot,
true, playerRoot
)
--]]
elseif player_Sides.Value == 5 then
--Static(workspace.Boundaries, playerRoot, opponentRoot)
--[[
Static(
workspace.Static_Left,
workspace.Static_Right,
true,
playerRoot,
opponentRoot, -5, 5,
playerRoot, true, opponentRoot
)
--]]
end
end)
game.ServerStorage.Bindables.Edge_Screen.Event:Connect(function(P2, P1)
CheckOutOfBounds(P2, P1)
end)
the script uses a code from street fighter boundary scripting support post with just some new stuff i made by making the boundary moves