Clickdetector on character is not working

So I’ve been trying to make a script where if you click on a character a gui will show up on the screen, however nothing is happening when I’m clicking on a character.
These are my scripts:
-This one is the script that adds a ClickDetector when a person joins the game

game.Players.PlayerAdded:Connect(function(plr)
	local User = Instance.new("Folder", game.ReplicatedStorage.Players)
	User.Name = plr.Name
	local val = Instance.new("StringValue", User)
	val.Name = "text"
	val.Value = "Nothing."
	plr.CharacterAdded:Connect(function(char)
		local cd = Instance.new("ClickDetector", char)
		cd.Name = "Click"
		local scriptclone = script.Clickd:Clone()
		scriptclone.Parent = char
		scriptclone.Enabled = true
	end)
end)

This script works.
-This is the script that runs when the clickdetector detects a click.

script.Parent.Click.MouseClick:Connect(function(plr)
	print("Clicked And User: "..plr.Name)
	plr.PlayerGui.ScreenGui.Other.Visible = true
	local user = script.Parent
	local usern = game.ReplicatedStorage.Players:FindFirstChild(script.Parent.Name, true)
	plr.PlayerGui.ScreenGui.Other.Text = usern.text.Value
end)

It also doesn’t print anything.

Thank you for reading.

Nevermind, it works but it doesn’t work on yourself, I tested with 2 players and it worked perfectly fine.

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