Same result
I really don’t understand why the billboard adornee is still in the middle of the baseplate
Edit: no errors appeared
Same result
I really don’t understand why the billboard adornee is still in the middle of the baseplate
Edit: no errors appeared
Is it at least setting the adornee this time lol
Hm. So I assume the text isn’t changing either?
No, nothing it’s just being visible with adornee = nil and text = " " but its visible when you get close to the seat
Oh I understand the problem MAYBE. Let me try to get a fix.
Ok let me explain my fix.
What we were doing previously was making multiple loops for every single seat. Every single seat so it will detect that some seats won’t be in distance, thus changing it to nil while it tries to change it to the seat.
So I fixed that using Heartbeat - it will check for the closest seat every frame in one thread, rather than multi-threading.
Read upon it and make sure you understand it though. Don’t wanna be throwing you fixes and you not learning from it.
local State,PreviousState = 0,0
local LockedOn = nil;
local Callbacks = {
[1] = function() -- State 1
Button.Button.Text = "F - Sit"
Button.Adornee = LockedOn
end;
[2] = function()
Button.Button.Text = ""
Button.Adornee = nil
end;
}
local function GetSeat()
local Seat,Mag = nil,math.huge -- Variables
for i,seat in pairs(workspace.SeatFolder:GetChildren())do
local SeatDistance = (player.Character.PrimaryPart.Position - seat.Position).Magnitude -- hold distance
if SeatDistance <= distance and SeatDistance < Mag then -- checks if it's within distance and closer than the current seat
Seat = seat
Mag = SeatDistance
end
end
return Seat;
end
game:GetService('RunService').Heartbeat:Connect(function() -- Every frame.
LockedOn = GetSeat()
local WaitTime = 0
if (LockedOn) then
State = 1
else
State = 2
WaitTime = .5
end
local TweenToPlay = State == 1 and tween or State == 2 and tween2
local Function = Callbacks[State];
if (PreviousState ~= State and TweenToPlay) then
spawn(function()
TweenToPlay:Play()
wait(WaitTime)
Function()
end)
end
PreviousState = State
end)
I will be reading the script, but i think I know what you have done. Thanks.
And it’s working so thanks!
Glad it finally works haha. And thanks.
Hello, It’s been sometime I was using the same script for a simulator I am working on solo and I tried my best but couldn’t figure it how to fix this small issue, and so I decided to contact you once again since you helped me originally.
The issue is that when I was close to an object (in this case Eggs) and get close to an other the E button stay on the first Egg instead of going to the closest Egg the player is close too as demonstrated in this GIF.
https://gyazo.com/b3377c1c7a701dd24361954751f8c3d2
Any sort of help would be great