Hi, I am trying to make a model that puts the username of any player that touches a brick into a surface gui. I am having difficulty with the username and have tried different options such as the getplayerfromcharacter. Below is the code I have so far. Any help is appreciated.
local character = game.Workspace.Player local player = game.Players:GetPlayerFromCharacter(character) screen = workspace.Screen.SurfaceGui.Frame.TextBox Sens = script.Parent local function OnTouch (Sens) screen.Text = ("Person Reset:" ..player.Name) end Sens.Touched:Connect (OnTouch)
function onTouch(characterBodyPart) local characterName = characterBodyPart.Parent.Name local humanoid = characterBodyPart.Parent:FindFirstChild("Humanoid") if humanoid then local screen = workspace.Screen.SurfaceGui.Frame.TextBox screen.Text = "Person Reset: "..characterName humanoid.Health = 0 end end script.Parent.Touched:Connect(onTouch)