Problem with Text(box/label)

Hello! I have a problem with my script that not change the text.

Here is my code:

local plr = script.Parent.Parent.Parent.Parent.Parent
local T = game:GetService("Teams")

script.Parent.MouseButton1Click:Connect(function()
	local S = game:GetService("ServerStorage")
	for i, v in pairs(T["Politie"]:GetPlayers()) do
		local C = S.TelefoonUI:Clone()
		C.MeldingFrame.Visible = false
		C.MeldingOntvang.Visible = true
		C.MeldingOntvang.LocatieTekst.Text = script.Parent.Parent.LocatieB.Text
		C.Parent = v.PlayerGui
	end
end)

From a textbox to a textlabel. I don’t have errors.

What is being clicked? You should stop using .Parent so many times so you can actually read your code. Make a few variables so you can tell what everything is and where things are.

image

From that button to the LocationText.

I would like to note that this could result in multiple UIs.
Perhaps they are over the top of one another and that is why you are not seeing any change. I must note that this is far from the most efficient way of achieving your goal (referring to your current script).

I suggest you instead make a UI that is always there and make a RemoteEvent that updates it on all the clients.

I have the solution when the local client changes the textbox, it’s locked in.

So if you want changes a textbox’s text you need to fire to local client.

2 Likes

maybe try to use :WaitForChild() like:

script.Parent.MouseButton1Click:Connect(function()
	local S = game:GetService("ServerStorage")
	for i, v in pairs(T["Politie"]:GetPlayers()) do
		local C = S.TelefoonUI:Clone()
		C:WaitForChild('MeldingFrame').Visible = false
		C:WaitForChild('MeldingOntvang').Visible = true
		C:WaitForChild('MeldingOntvang').LocatieTekst.Text = script.Parent.ParentC:WaitForChild('LocatieB').Text
		C.Parent = v.PlayerGui
	end
end)

Or he can make it local script.

Yeah, but i don’t know if this situation of the script is more good to put in Server Side or Client Side

Oh i know his problem. First of all ServerScript Wont run in client side StarterGui, PlayerScript, etc. Second, you cant call MouseButton1Click on a server. you never can

I have created the RemoteEvent but that gives me this error:

Code:

script.Parent.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.MeldingSysteem.MeldingOntvangen:FireClient(script.Parent.Parent.MeldingB.Text, script.Parent.Parent.LocatieB.Text, script.Parent.Parent.TeamsB.Text)
end)

The first args of FireClient is A Player So you have to put player first

script.Parent.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.MeldingSysteem.MeldingOntvangen:FireClient(player,script.Parent.Parent.MeldingB.Text, script.Parent.Parent.LocatieB.Text, script.Parent.Parent.TeamsB.Text)
end)

on FireClient() You need the player target/player you want to call first

script.Parent.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.MeldingSysteem.MeldingOntvangen:FireClient(*PlayerTragetHere*,script.Parent.Parent.MeldingB.Text, script.Parent.Parent.LocatieB.Text, script.Parent.Parent.TeamsB.Text)
end)

I have the solution of your problem:

script.Parent.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.MeldingSysteem.MeldingOntvangen:FireAllClients(script.Parent.Parent.MeldingB.Text, script.Parent.Parent.LocatieB.Text, script.Parent.Parent.TeamsB.Text)
end)
1 Like

Yep, only it doesn’t show the UI.

This is my script:

local T = game:GetService("Teams")

game.ReplicatedStorage.MeldingSysteem.MeldingOntvangen.OnServerEvent:Connect(function(plr, Melding, Locatie, Teams)
	local C = game:GetService("ServerStorage").TelefoonUI:Clone()
	for i, v in pairs(T["Politie"]:GetPlayers()) do
	C.MeldingOntvang.LocatieTekst = Melding.Text
	C.MeldingOntvang.Visible = true
	C.MeldingFrame.Visible = false
	C.Parent = v.PlayerGui
		end
	
end)

you can’t access ServerStorage in Client Side
I have a solution for you problem:

Server:

local T = game:GetService("Teams")
script.Parent.MouseButton1Click:Connect(function()
	for i, plr in pairs(T["Politie"]:GetPlayers()) do
		local C = game:GetService("ServerStorage").TelefoonUI:Clone()
		C.MeldingOntvang.Visible = true
		C.MeldingFrame.Visible = false
		C.Parent = plr:WaitForChild("PlayerGui")
		game.ReplicatedStorage.MeldingSysteem.MeldingOntvangen:FireClient(plr,script.Parent.Parent.MeldingB.Text)
	end
end)

Client:

game.ReplicatedStorage.MeldingSysteem.MeldingOntvangen.OnServerEvent:Connect(function(Melding)
	game.Players.LocalPlayer:WaitForChild("PlayerGui").MeldingOntvang.LocatieTekst = Melding.Text
end)

And where should I place both scripts? Because my server script was in Serverscriptservice.

You need to put the Server Script and Client Script inside your button

Have you write a mistake?

MeldingSysteem

No in the name is no mistake,

Its show now the UI but the Text is not changing…
image