When clicking textbutton, it will team nearest player prisoner.
Teams yourself prisoner.
Local Script:
local player = game.Players.LocalPlayer
local players = game.Workspace:WaitForChild("Players")
local rs = game:GetService("ReplicatedStorage")
local folder = rs:WaitForChild("remotes")
local name = script.Parent.Parent.Username
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
function Open()
local Character = LocalPlayer.Character
local HumanoidRootPart = Character and Character:FindFirstChild("HumanoidRootPart")
if not (Character or HumanoidRootPart) then return end
local TargetDistance = math.huge
local Target
for i,v in ipairs(Players:GetPlayers()) do
if v ~= LocalPlayer and v.Character and v.Character:FindFirstChild("HumanoidRootPart") then
local TargetHRP = v.Character.HumanoidRootPart
local mag = (HumanoidRootPart.Position - TargetHRP.Position).magnitude
if mag < TargetDistance then
TargetDistance = mag
Target = v
print(Target.Name)
print("Fired")
folder.book:FireServer(player,Target)
end
end
end
end
script.Parent.MouseButton1Down:Connect(Open)
Server Script:
local rs = game:GetService("ReplicatedStorage")
local folder = rs:WaitForChild("remotes")
folder.book.OnServerEvent:Connect(function(player,Target)
print("Recieved")
Target.Team = game.Teams.Prisoner
end)
I’ve fixed that, but now I am trying to figure out how I would make if you put a time in a text label, how would you wait how long that text label says
Does this put them on the team for 10 seconds? If not, that isn’t the case and I don’t know what else to tell you without the code and some sort of error.
So it just puts them on the team and removes them immediately or after 1 second? If immediately, check the location of it and try again, make sure the value is still in the TextBox, also try print the TextBox.Text just before wait and see what it says.