hello everyone, could someone help me reproduce this mechanic [when the player jumps it will cross the part and then play normally], I’m having a lot of difficulty reproducing it, I’m a beginner
example video
hello everyone, could someone help me reproduce this mechanic [when the player jumps it will cross the part and then play normally], I’m having a lot of difficulty reproducing it, I’m a beginner
example video
The way that I can think of is to have a zone below the part, then check if the player is touching that zone. Here is some code that works most of the time, but still should resemble what you are looking for.
local zone = script.Parent.Zone
local touchingparts = {}
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local inZone = false
for i,v in ipairs(hit.Parent:GetChildren()) do
if table.find(touchingparts, v) then
inZone = true
end
end
if inZone then
script.Parent.CanCollide = false
else
script.Parent.CanCollide = true
end
end
end)
zone.Touched:Connect(function(hit)
if not table.find(touchingparts, hit) then
table.insert(touchingparts, hit)
end
end)
zone.TouchEnded:Connect(function(hit)
if table.find(touchingparts, hit) then
table.remove(touchingparts, table.find(touchingparts, hit))
end
end)
script.Parent is the platform, and the variable “zone” is the zone in which the player is in before the jump. This is my first post, so please tell me if I am wrong or doing something incorrectly.
wouldn’t there need to be a delay before setting the CanCollide so the character can go through the part?
Check every heartbeat whether the player is moving up or down. If moving up, all one-way platforms are uncollidable. Otherwise, they are collidable.
@oxzics’s method may work, but it would be hard to add more one-way platforms. Every platform needs a zone below it, and it wouldn’t automatically follow resizing and maybe positioning of the platform.
I’m assuming that the script is server sided because it has no LocalPlayer checks. That makes a delay for all players, which will not end up well for anybody.
I can guarantee you that the game in the video is using my method due to it’s simplicitiy. Trust me, it should be easier to code, and it should be shorter. I’m not spoonfeeding code because of how small it is. You would need to utilize:
game:GetService("RunService").Heartbeat
local char = game.Players.LocalPlayer.Character
(inside connection)char.HumanoidRootPart.AssemblyLinearVelocity
for _, platform in pairs(
…platform.CanCollide =
…thank you very much for your help I tried to reproduce your method in ServerScript but I couldn’t I’m a little confused
local parts = game.Workspace.Model:GetChildren()
game:GetService("RunService").Heartbeat:Connect(function()
local char = game. Players.LocalPlayer.Character
char.HumanoidRootPart. AssemblyLinearVelocity = Vector3.new(0, 1, 0)
for_, platform in pairs(parts) do
platform.CanCollide = false
end
end)|
Your script will:
This doesn’t make much sense. Instead, get the velocity and compare it’s Y value to 0 to see if the player is moving upwards. If it is, all platforms are uncollidable. If the character is moving down, it will be collidable.