I would like to preface this topic by stating that I’ve poked around the other topics with similar names but they seem to be taking an entirely different approach to this. I would also like to clarify that I am fairly new to scripting.
So the general goal of this script is to get the name of the player’s character when they’ve stepped on the part and thus have the text label state, (Character.Name…“is king of the hill”). I seem to have hit a snag though as it’s not doing anything and I have no error. I’ve poked around a bit in the API and I’m not sure what I’ve done wrong. I do believe that the solution is probably a simple one though.
local part = script.Parent
local debounce = false
local playersService = game:GetService("Players")
local players = playersService:GetPlayers()
part.Touched:Connect(function(hit)
local hitParent = hit.Parent
local humanoid = hitParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
if not debounce then
debounce = true
for i, v in pairs(players)do
v.PlayerGui.ScreenGui.Frame.TextLabel.Text = (hit.Parent.Name.."is king of the hill")
end
wait(1)
debounce = false
end
end
end)
This is the script which is inside the part, it is currently the only script inside the game.