Help with checking if a character in the workspace with the same name as a player is a player

i see why now… im gonna give this a rather instant fix in like 3 or 5 mins

thank you very much for all your thought

Put the KillEvent inside of ReplicatedStorage, And make a script in ServerScriptService containing this:

function CheckPlr(partialuser)
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.Name:lower():sub(1,#partialuser) == partialuser:lower() or v.DisplayName:lower():sub(1,#partialuser) == partialuser:lower() then
			return v.Name
		end
	end
end

local event = game:GetService("ReplicatedStorage").KillEvent

event.OnServerEvent:Connect(function(plr, name:string)
	local target = game.Players:FindFirstChild(name)
	if target then
		local char = target.Character
		if char then
			char:FindFirstChild("Humanoid").Health=0
		end
	end
end)

Also, With the new CheckPlr addition, You no longer have to insert the full username, Instead a part of the username, And you can even use displaynames now.

updated code a slight bit (small mistake of me)

still not working? + button gets deleted???

server script:

local event = script.Parent.KillEvent
event.Parent = game.ReplicatedStorage

event.OnServerEvent:Connect(function(plr, name)
	local foundchar = plr.Character
	if foundchar then -- if a character is found
		local foundplr = game.Players:GetPlayerFromCharacter(foundchar) 
		if foundplr ~= nil and foundchar~=nil then
			foundchar.Humanoid.Health = 0
		end
	end
end)

local script:

local button = script.Parent
local textbox = script.Parent.Parent.CMDBAR
local event = script.Parent.KillEvent
event.Parent = game.ReplicatedStorage

button.MouseButton1Click:Connect(function()
	local name = textbox.Text
    event:FireServer(name)
end)

I put this line inside of a seperate script containing the previous code you gave me.
image

in studio (you can see the button is there)
image

in game (button is gone)
image

This is how it should look like
image

how do I make this automatic? and what is all the base64 stuff?

Well, That is an encoder for my CFrame animation editor (rather complex)

And you don’t automate this, You must do it manually

Or if u want to, You can send me a friend request and add me to the TeamCreate so i can fix it directly

alright, I would love that but its my friends game so you can add him. His username is Rockingwiiing and his DisplayName is Rock. He is on call with me right now and says he will add you back.

Sent the friend request to him.

Perfect, he just added you back and saved a copy.

Join the team test so i can test it myself

Thank you so much and that team create session was amazing lol, good luck with your project and thanks again

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.