Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

RemoteEvent change GUI text not working?

Asked by
haba_nero 386 Moderation Voter
4 years ago

Ok, guys! I am trying to make an SCP game. I want to have the description change when the player clicks a button stating a role(Class-D, MTF, etc). Each button has a LocalScript. That script sends data to a RemoteEvent, which then sends the message to a Script that is supposed to change the text. But I keep getting an error! Please help me!

Hierarchy of GUI:

https://postimg.cc/nsD2jLY2

ServerScript:

local Title = script.Parent:FindFirstChild("TeamName")
local Desc = script.Parent:FindFirstChild("TeamDesc")
local Event = script.Parent.Parent:FindFirstChild("MakeTeam")
Event.OnServerEvent:Connect(function(title,desc)
    Title.Text = title
    Desc.Text = desc
end)

LocalScript:

script.Parent.MouseButton1Click:Connect(function()
    local Event = script.Parent.Parent.Parent.Parent:FindFirstChild("MakeTeam")
    Event:FireServer(script.Parent.Text,script.Parent:FindFirstChild("Desc").Value)
end)

The error I am getting:

19:48:41.078 - Players.TheLastHabanero.PlayerGui.ScreenGui.Desc.Script:5: bad argument #3 to 'Text' (string expected, got Object)

Thanks for any help!

1 answer

Log in to vote
1
Answered by 4 years ago

I'm not entirely sure, but in the server script on line 5, you have this:

Event.OnServerEvent:Connect(function(title,desc)

I believe you need to have 3 variables in the :Connect(function(). The 3rd variable, (Technically 1st) would be for the player, the following ones would be data transmitted through the remote event. (The title and desc)

Like I said though, I don't know for sure if this is it, but try it and tell me if it doesn't work.

0
(Sorry, on line 4 you have that) kkkeelan999 92 — 4y
0
Yup it worked! Just added a random "par" variable to it! Thanks! haba_nero 386 — 4y
Ad

Answer this question