Localscript not updating text when remote event is fired

Title says it all. When a clickdetector is clicked, then the remote event is fired through the server script in the click detector.

Server Script

local Part = script.Parent.Parent
local PartClickDetector = Part:WaitForChild("ClickDetector", 2)

PartClickDetector.MouseClick:Connect(function(player)
	local character = player.Character
	local hum = character:WaitForChild("Humanoid")

	local Torso = character:WaitForChild("Torso")
	local RightLeg = character:WaitForChild("Right Leg")
	local LeftLeg = character:WaitForChild("Left Leg")
	local RightArm = character:WaitForChild("Right Arm")
	local LeftArm = character:WaitForChild("Left Arm")
	local Head = character:WaitForChild("Head")
	local Hat = script:WaitForChild("ROBLOXRBaseballCap")
	
	if Torso then
		Torso.BrickColor = BrickColor.new("Bright blue")
		RightLeg.BrickColor = BrickColor.new("Br. yellowish green")
		LeftLeg.BrickColor = BrickColor.new("Br. yellowish green")
		RightArm.BrickColor = BrickColor.new("Bright yellow")
		LeftArm.BrickColor = BrickColor.new("Bright yellow")
		hum:AddAccessory(Hat)
		character.ClothesOn.Value = true
		game.ReplicatedStorage.ClothesOn:FireClient(player)
		print("rem1 fired")
	end
end)

Client Script

local label = script.Parent
local text = label.Text
local rem1 = game.ReplicatedStorage.ClothesOn
text = "current objective: put some clothes on"

rem1.OnClientEvent:Connect(function(player)
	text = "current objective: leave the house"
end)

This stores the current text that is located within label.Text, and after the initial setting of the variable, has nothing to do with the TextLabel. Because of this, it can NOT be used to adjust the text in the label.

The updated client code will have to look like:

local label = script.Parent
local rem1 = game.ReplicatedStorage.ClothesOn
label.text = "current objective: put some clothes on"

rem1.OnClientEvent:Connect(function(player)
	label.text = "current objective: leave the house"
end)


Ahhhh! Sorry, I haven’t coded in a while and I forgot about this. Thank you so much!

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