On the event, this would change the text of a text label to a set of values(a string and an integer) both set in another part. value1 is the integer and value2 is the string. When I run it, it gives the correct value for value1 but it says that value2 is nil. I tried taking value2 out of tosring since it is a string already but it gave me an error that said, “attempt to concatenate nil with string”.
local event = game:GetService("ReplicatedStorage"):WaitForChild("??")
local label = script.Parent.Frame.TextLabel
event.OnClientEvent:Connect(function(player, value1, value2)
label.Text = "Do you want to buy "..tostring(value2).." for "..tostring(value1).." coins?"
script.Parent.Visible = true
The event is fired from a part in the workspace. It fires the event once someone touches it. This part is also where the values are stored. Here’s the script for it:
local function onTouch(part)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
if not debounce then
debounce = true
local value1 = script.Parent.Strng.Value
local value2 = script.Parent.Int.Value
local player = game.Players:GetPlayerFromCharacter(part.Parent)
event:FireClient(player, value1, value2)
debounce = false
.OnClientEvent() doesn’t have the player who received the signal as the first argument. This is only the case for .OnServerEvent() connections. So, only value1 and value2 are the arguments. In fact, if you print player you may find it has the value of value1.