Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The code isn't working it won't change the text label?

script in serverscriptstorage

local part = game.Workspace.Part
local whoClicked = game:GetService("ReplicatedStorage").whoClicked

part.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
	whoClicked:FireAllClients(playerWhoClicked)
end)

local script in screengui

local whoClicked = game:GetService("ReplicatedStorage").whoClicked

whoClicked.OnClientEvent:Connect(function(playerWhoClicked)
	game:GetService("Players").LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = playerWhoClicked 
end)

1 comment

0

playerWhoClicked.Name

1 answer

✓ Accepted answer

Your problem is that the game doesn't know whats playerWhoClicked so it doesn't know what to do and you get an error.

I'll do the work for you:

Script in ServerScriptService:

local part = game.Workspace.Part
local whoClicked = game:GetService("ReplicatedStorage").whoClicked

part.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
    whoClicked:FireAllClients(playerWhoClicked)
end)

Script in ScreenGui:

local whoClicked = game:GetService("ReplicatedStorage").whoClicked

whoClicked.OnClientEvent:Connect(function(playerWhoClicked)
    game:GetService("Players").LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = playerWhoClicked.Name
end)

If this works please accept my answer, It helps me and you

This discussion is preserved as it was. New answers, comments, and votes are closed.