Blackboard with TextLabel change by player not working

Hi,

I made a Blackboard model where players with the “Teacher” role can interact with the blackboard through a prompt and change the text. I did this simply using a screen GUI with a text label and a button. There is no error in the output, but for some reason nothing is working.

If someone could take a look and let me know what the issues is please lmk! Thanks :slight_smile:

The blackboard model hiarchy

image

Prompt Script:

local proximityPrompt = script.Parent
local Players = game:GetService("Players")

local function onCharacterAdded(character)
	local player = Players:GetPlayerFromCharacter(character)
	if player then
		local playerTeam = player.Team
		if playerTeam and playerTeam.Name == "Teacher" then
			proximityPrompt.Enabled = true
		else
			proximityPrompt.Enabled = false
		end
	end
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end)

for _, player in pairs(Players:GetPlayers()) do
	if player.Character then
		onCharacterAdded(player.Character)
	else
		player.CharacterAdded:Connect(onCharacterAdded)
	end
end

StarterGUI Hiarchy

image

LocalScript in Frame

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local changeBlackboardTextEvent = ReplicatedStorage:WaitForChild("ChangeBlackboardText")

local frame = script.Parent
local textBox = frame:FindFirstChild("TextBox")
local submitButton = frame:FindFirstChild("SubmitButton")

submitButton.MouseButton1Click:Connect(function()
	local newText = textBox.Text
	changeBlackboardTextEvent:FireServer(newText)
	frame.Parent.Enabled = false
end)

ServerScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local changeBlackboardTextEvent = Instance.new("RemoteEvent", ReplicatedStorage)
changeBlackboardTextEvent.Name = "ChangeBlackboardText"

local blackboardModel = workspace:WaitForChild("BlackboardModel")
local blackboardSurface = blackboardModel:WaitForChild("BlackboardSurface")
local surfaceGui = blackboardSurface:WaitForChild("SurfaceGui")
local textLabel = surfaceGui:WaitForChild("TextLabel")

changeBlackboardTextEvent.OnServerEvent:Connect(function(player, newText)
	textLabel.Text = newText
end)

setting prompt.enabled to true/false will enable/disable the prompt for all players, so if a teacher character loads and then another character loads. the prompt will be disabled for the teacher too

1 Like

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