So, I am trying to make a button that changes a team and also changes a Value, which is in PlayerGui. Using remoteevetns, I am trying to figure out how to change something in the PlayerGui from the script in ServerScriptService. Is there anybody who could tell me how to do this?
Here's something I wrote up similar to what I am trying to do:
Script in ServerScriptService (Script):
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TestEvent = Instance.new("RemoteEvent")
TestEvent.Parent = ReplicatedStorage
TestEvent.Name = "TestEvent"
local function TestEventRequest(player,TestValue)
player.TeamColor = BrickColor.new("Bright red")
TestValue = "Red"
end
TestEvent.OnServerEvent:Connect(TestEventRequest)
Script in TextButton (LocalScript):
function click()
local TestValue = script.Parent.Parent.Parent.TestValue.Value
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Test = ReplicatedStorage:WaitForChild("TestEvent")
wait (0.02)
Test:FireServer(TestValue)
end
script.Parent.MouseButton1Down:connect(click)

3 comments
Why not access PlayerGui inside click() ....
Because there are certain things I can only do in ServerScriptStorage that I can't do in PlayerGui and I need variables from the script in order for the script to work the way I would like for it to.
If you can't simply use a value in ReplicatedStorage then use a remote function instead of a remote event.