The code i made that didnt work
function OnClick() game.StarterGui.ScreenGui.TextLabel.Text = "works" end script.Parent.ClickDetector.MouseClick:connect(OnClick)
Hello, I made a new script for you, I see that the other persons script works so I made a new one where you can change the text anytime very quickly!
Script in ClickDetector:
local replicatedStorage = game:GetService("ReplicatedStorage") script.Parent.MouseClick:Connect(function() replicatedStorage:FindFirstChild("ChangeText"):FireAllClients("Works") -- Change to the text you want! end)
LocalScript in TextLabel:
local replicatedStorage = game:GetService("ReplicatedStorage") replicatedStorage:FindFirstChild("ChangeText").OnClientEvent:Connect(function(text) script.Parent.Text = tostring(text) end)
Really simple.
function OnClick(player: Player) player.PlayerGui.TextLabel.Text = "works" end script.Parent.ClickDetector.MouseEnter:Connect(OnClick)
You're changing it so it shows up when they respawn or anyone.
MouseEnter (NOT MOUSECLICK!) has a player argument to get the player.
The fastest way to do this would actually be via the use of remotes. Its finicky to use a server sided script to change a players UI.
First create a remote event within ReplicatedStorage, name it whatever you want. I went with ClickRemote.
Inside of a local script inside of the text box your code should look like this:
local Remote = game.ReplicatedStorage.ClickRemote Remote.OnClientEvent:Connect(function() script.Parent.Text = "Text to set to" end)
Inside of the server script you can setup your code to detect clicks and fire the remote towards the player that clicks:
local ClickDetector = script.Parent.ClickDetector local Remote = game.ReplicatedStorage.ClickRemote local function HandleAClick(PlayerThatClicked) Remote:FireClient(PlayerThatClicked) end ClickDetector.MouseClick:Connect(HandleAClick)
This will change the text of the UI
hey you! have you ever heard of enes? if you are in trouble, better call enes!