local ReplicatedStorage = game:GetService("ReplicatedStorage");
local TweenService = game:GetService("TweenService");
local RunService = game:GetService("RunService");
local Players = game:GetService("Players");
local LocalPlayer = Players.LocalPlayer;
local SellBooth = workspace:WaitForChild("SellBooth");
local BuyBooth = workspace:WaitForChild("BuyBooth");
local SellNPC = SellBooth:WaitForChild("Rig");
local BuyNPC = BuyBooth:WaitForChild("Rig");
local NPCNeck = SellNPC:WaitForChild("Head"):WaitForChild("Neck");
local CFrame0 = NPCNeck.C0;
local Modules = ReplicatedStorage:WaitForChild("Modules");
local module = require(Modules:WaitForChild("TextModule"));
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui");
local BillboardGui = PlayerGui:WaitForChild("SellOptions");
BillboardGui.Adornee = SellNPC:WaitForChild("HumanoidRootPart");
local SellDebounce = false;
local BuyDebounce = false;
local SellActive = false;
local Annoyed = 0;
local SellOptions = {
[1] = '["I want to sell my inventory"]';
[2] = '["I want to sell this"]';
[3] = '["How much is this worth?"]';
[4] = '["Nevermind"]';
}
local function CloseSell()
SellActive = false;
for i = 1, 4, 1 do
BillboardGui[i].Visible = false;
end;
end;
SellNPC.ProximityPrompt.Triggered:Connect(function(player)
if SellDebounce == true then return; end;
SellDebounce = true;
if SellActive == true then
Annoyed += 1;
if Annoyed == 3 then
module.AnimateText(
"<bold><red><shake>Dude...</shake></red></bold>",
SellNPC.Head.TextBox,
0.04,
Enum.Font.Arial,
"fade diverge",
1,
24
);
else
module.AnimateText(
"<bold>Use my righthand menu to choose what you want to do!</bold>",
SellNPC.Head.TextBox,
0.04,
Enum.Font.Arial,
"fade diverge",
1,
24
);
end
task.wait(1.5);
module.ClearText(SellNPC.Head.TextBox, {
direction = "right",
duration = 0.3,
order = "reverse"
});
SellDebounce = false;
return;
end;
coroutine.wrap(function()
Annoyed = 0;
module.AnimateText(
"<bold>Have anything to <wave><color=#FFFF00>sell</color></wave>?</bold>",
SellNPC.Head.TextBox,
0.04,
Enum.Font.Arial,
"fade diverge",
1,
24
);
task.wait(3);
module.ClearText(SellNPC.Head.TextBox, {
direction = "right",
duration = 0.3,
order = "reverse"
});
SellDebounce = false;
end)()
task.wait(0.75)
SellActive = true;
for i = 1, 4, 1 do
BillboardGui[i].Visible = true;
task.wait(0.15);
end;
end);
BuyNPC.ProximityPrompt.Triggered:Connect(function(player)
if BuyDebounce == true then return; end;
BuyDebounce = true;
coroutine.wrap(function()
module.AnimateText(
"<bold>Interested in <wave><color=#FFFF00>buying</color></wave> anything?</bold>",
BuyNPC.Head.TextBox,
0.04,
Enum.Font.Arial,
"fade diverge",
1,
24
);
task.wait(3);
module.ClearText(BuyNPC.Head.TextBox, {
direction = "right",
duration = 0.3,
order = "reverse"
});
BuyDebounce = false;
end)();
task.wait(0.75);
ReplicatedStorage.Events.BuyNPC:FireServer("Part");
end);
script.UIListLayout.Parent = BillboardGui;
local SellFunctions = {
[1] = function()
end,
[2] = function()
end,
[3] = function()
end,
[4] = function()
CloseSell();
end,
}
for Number, Text in pairs(SellOptions) do
local Clone = script.Button:Clone();
Clone.Number.Text = string.format("#%s", Number);
Clone.TextLabel.Text = string.format("%s", Text);
Clone.Name = Number;
Clone.Parent = BillboardGui;
local HoverTween = TweenService:Create(
Clone.TextLabel,
TweenInfo.new(0.5),
{
Position = UDim2.new(0.1,0,0,0);
}
);
local UnhoverTween = TweenService:Create(
Clone.TextLabel,
TweenInfo.new(0.25),
{
Position = UDim2.new(0.05,0,0,0);
}
);
Clone.MouseButton1Click:Connect(function()
SellFunctions[Number]();
end);
Clone.MouseEnter:Connect(function()
HoverTween:Play();
end);
Clone.MouseLeave:Connect(function()
UnhoverTween:Play();
end);
end
local function NPCLookAt(NPC)
local InFront = NPC.PrimaryPart.CFrame:ToObjectSpace(LocalPlayer.Character.PrimaryPart.CFrame).Z < 0;
local unit = CFrame0 * CFrame.new(Vector3.new(0,0,0));
if (NPC.PrimaryPart.Position - LocalPlayer.Character.PrimaryPart.Position).magnitude <= 26 and InFront then
unit = -(NPC.PrimaryPart.CFrame.p - LocalPlayer.Character.PrimaryPart.Position).unit;
NPCNeck.C0 = CFrame0 * CFrame.new(Vector3.new(0, 0, 0), unit);
else
if SellActive == true then
CloseSell();
end;
local currentRotation = NPCNeck.C0;
local targetRotation = CFrame0;
local lerpValue = 0.1;
NPCNeck.C0 = currentRotation:Lerp(targetRotation, lerpValue);
end;
end;
RunService.RenderStepped:Connect(function(DeltaTime)
if LocalPlayer.Character then
NPCLookAt(SellNPC);
end;
end);