everything works fine until up to here. instead of getting only the player from the textbox, it gets every player and kills everyone instead of just the target player. tysm:
problem area:
yes.MouseButton1Click:Connect(function()
plrchoiceUI.Enabled = false
selectedButton.BackgroundColor3 = unselectedColor
local findPlr:Player = plrs:FindFirstChild(templateClone.Text)
if findPlr then
if findPlr.Character.Humanoid.Health > 0 then
findPlr.Character.Humanoid.Health = 0
end
end
end)
script:
local template = game.ReplicatedStorage.plrName
local plrs = game:GetService("Players")
local unselectedColor = Color3.fromRGB(199, 199, 199) -- grey/white
local selectedColor = Color3.fromRGB(97, 255, 62) -- Green
local plrchoiceUI = script.Parent.plrChoiceUI
local selectedButton -- Stores the button you clicked on
local plrchoiceUI = script.Parent.plrChoiceUI
local yes = plrchoiceUI.Frame.yes
local no = plrchoiceUI.Frame.no
function updPlrs()
local plr = game.Players.LocalPlayer
local thumbnailtype = Enum.ThumbnailType.HeadShot
local thumbnailsize = Enum.ThumbnailSize.Size420x420
for i, p in ipairs(game.Players:GetPlayers()) do
if (script.Parent.plrScroll:FindFirstChild(p.Name)) then continue end
local thumbnail = plrs:GetUserThumbnailAsync(p.UserId, thumbnailtype, thumbnailsize)
local templateClone = template:Clone()
templateClone.Name = p.Name
templateClone.Visible = true
templateClone.Text = p.Name
templateClone.displayName.Text = "@"..p.DisplayName
templateClone.PFP.Image = thumbnail
templateClone.Parent = script.Parent.plrScroll
--if a player slot was clicked
templateClone.MouseButton1Click:Connect(function()
if selectedButton then
selectedButton.BackgroundColor3 = unselectedColor -- Reset the current selected button's color
end
templateClone.BackgroundColor3 = templateClone and selectedColor or unselectedColor
selectedButton = templateClone -- Rewrite the selectedButton
if templateClone and templateClone.BackgroundColor3 == selectedColor then
plrchoiceUI.Enabled = true
plrchoiceUI.Frame.question.Text = "Are you sure you would like to loopkill "..templateClone.Text.."?"
end
end)
yes.MouseButton1Click:Connect(function()
plrchoiceUI.Enabled = false
selectedButton.BackgroundColor3 = unselectedColor
local findPlr:Player = plrs:FindFirstChild(templateClone.Text)
if findPlr then
if findPlr.Character.Humanoid.Health > 0 then
findPlr.Character.Humanoid.Health = 0
end
end
end)