Help with a overhead script

so, for some reason this script doesn’t show any errors,

local group = 6207547
local host = script.HOSTGUI.HOST -- where its located

game.Players.PlayerAdded:Connect(function(player) -- define player
	player.Chatted:Connect(function(msg) -- (chat)
		if player:GetRankInGroup(group) >= 5 then -- certain rank to gain overhead script
			if msg == ":host" or ":Host" then -- what they need to say
				local clone = script.HOSTGUI:Clone() -- clones 
				player.CharacterAdded:Connect(function(character) -- what is a character
					clone.Parent = character.Head -- puts it on head
					wait(1) -- waits a second before (just incase time issues)
					clone.HOST.visible = true -- becomes visible 
		
				end)
			end
		end
	end)
end)

This is a Server Script, inside ServerScriptService correct? :thinking:

Also instead of adding multiple if statements, you can break it down by encasing it all into 1 using the and statement

yes there is, its located inside

I’m pretty sure your issue is because it only parents the clone on respawn, when y our character is added again, and you have a few more things that should be fixed around

This would always run the code inside it because of the :Host part, which will always return true, it’s better if you lower case the message and compare it to the lower case equivalent

And since only select people can use the Host command, unless you plan on adding more commands, it’s preferable to check if their rank is 5 or above before making the chatted event

And once again, finally, you can just use player.Character instead of a character added event in this case

local group = 6207547
local host = script.HOSTGUI

game.Players.PlayerAdded:Connect(function(player) -- define player
	if player:GetRankInGroup(group) >= 5 then
		player.Chatted:Connect(function(msg) -- (chat)
			if msg:lower() == ":host" and player.Character then -- what they need to say
				local clone = host:Clone() -- clones 
				clone.Parent = player.Character.Head -- puts it on head
				wait(1) -- waits a second before (just incase time issues)
				clone.HOST.Visible = true -- becomes visible 
			end
		end)
	end
end)
1 Like

thank you that fixed it! (how is it not 3O chars…)

1 Like