I’d actually put a Touched Part (a hitbox the size of the button and player’s height above the button to see if that works.
It may just be the fact the player is moving on the thin Part and the touched event is firing, then not firing.
you mean put a cancolide part that the player will touch?
i mean if my code doesn’t work then if anybody can help me and tell me how can i create my goal
button that when player stand on it will go down and when player step off it will go back up like in this example:
Yes, but make it smaller in the x and z axes and as tall as the player so any contact between the player’s limbs etc. will fire it.
Also make it above the button by about .2 studs so that the button touching it won’t fire the function.
i will try it right now i hope it work
still doesn’t work, still jitter up and down.
i am hopeless right now i think i will stop trying i am trying to fix it about 2 days and still can’t
So the print
statements are only firing once per each time you step on and off the button?
I tested out the code and I think it is a physics quirk.
As the part moves down with the character on top it is firing the touchended as the part is literally being pulled out from underneath. Then as the character falls, fires touched again. Which is why it jitters around without debounces.
That’s why I suggested a larger Part as a hitbox above the button. It didn’t fix the issue though.
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local part = script.Parent
local originalPosition = part.Position
local downPosition = originalPosition - Vector3.new(0, 2, 0)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
while true do
local ChrT = {}
for k, v in Players:GetPlayers() do
if not v.Character then continue end
table.insert(ChrT, v.Character)
end
local overlapParams = OverlapParams.new()
overlapParams.FilterType = Enum.RaycastFilterType.Whitelist
overlapParams.MaxParts = 50
overlapParams.FilterDescendantsInstances = {ChrT}
local partT = workspace:GetPartsInPart(part, overlapParams)
local FindHRP = false
for k, v in partT do
local Chr = v.Parent
local Plr = Players:GetPlayerFromCharacter(Chr)
if Plr then
FindHRP = true
end
end
local IsTweenDown, IsTweenUp = false, false
if FindHRP then
if not IsTweenDown then
IsTweenDown = true
local tweenDown = TweenService:Create(part, tweenInfo, {Position = downPosition})
tweenDown:Play()
tweenDown.Completed:Wait()
IsTweenDown = false
end
else
if not IsTweenUp then
IsTweenUp = true
local tweenUp = TweenService:Create(part, tweenInfo, {Position = originalPosition})
tweenUp:Play()
tweenUp.Completed:Wait()
IsTweenUp = false
end
end
task.wait(0.1)
end
hey firstly thanks for you try for helping me i appreciate it a lot.
i took your code and runed it and still jitter up and down wiredly as you can see here in the footage:
https://gyazo.com/085614029c8246bd7e201677c8827efe
as you can see i don’t even move on the part
Add “Break” it will stop the script
in what part of the code add Break?(line)
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local part = script.Parent
local originalPosition = part.Position
local downPosition = originalPosition - Vector3.new(0, 2, 0)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
while true do
local ChrT = {}
for k, v in Players:GetPlayers() do
if not v.Character then continue end
table.insert(ChrT, v.Character)
end
local overlapParams = OverlapParams.new()
overlapParams.FilterType = Enum.RaycastFilterType.Whitelist
overlapParams.MaxParts = 50
overlapParams.FilterDescendantsInstances = {ChrT}
local partT = workspace:GetPartsInPart(part, overlapParams)
local FindHRP = false
for k, v in partT do
local Chr = v.Parent
local Plr = Players:GetPlayerFromCharacter(Chr)
if Plr then
FindHRP = true
end
end
local IsTweenDown, IsTweenUp = false, false
if FindHRP then
if not IsTweenDown then
IsTweenDown = true
local tweenDown = TweenService:Create(part, tweenInfo, {Position = downPosition})
tweenDown:Play()
tweenDown.Completed:Wait()
IsTweenDown = false
end
else
if not IsTweenUp then
IsTweenUp = true
local tweenUp = TweenService:Create(part, tweenInfo, {Position = originalPosition})
tweenUp:Play()
tweenUp.Completed:Wait()
IsTweenUp = false
end
end
task.wait(0.1)
break
end
doesn’t work. its not running even one time when i stand on it.
still don’t work. even not once running