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

how do i solve this error attempt to concatenate local 'awardd' (a nil value)?

Asked by 5 years ago
Edited 5 years ago

im getting this errorServerScriptService.award:6: attempt to concatenate local 'awardd' (a nil value)

im trying to make a thing where u put text in textboxes then when u press submit ur text comes up on a surface gui

heres my code

client::

local remote = game.ReplicatedStorage.award

script.Parent.MouseButton1Click:Connect(function()
    remote:FireServer(script.Parent.Parent.Name.Text, script.Parent.Parent.Award.Text)
end)

server:

local remote = game.ReplicatedStorage.award

remote.OnServerEvent:Connect(function(player, awardd)
    game.Workspace.Screen.MainScreen.SurfaceGui.StartPage.Visible = false
    game.Workspace.Screen.MainScreen.SurfaceGui.Award.Visible = true
    game.Workspace.Screen.MainScreen.SurfaceGui.Award.TextLabel.Text = "Congratulations, "..player.." you have won the "..awardd
    print(player, awardd)
end)

3 answers

Log in to vote
0
Answered by
Prestory 1395 Moderation Voter
5 years ago
Edited 5 years ago

I have rewritten your code for you and updated it a little bit the problem was since you called the TextBox 'Name' it was bugging out and also you needed 3 arguments in the server script which you only put two here is the updated code!

Client

--LocalScript

local Remote = game:GetService('ReplicatedStorage'):WaitForChild('award')

function ButtonPress ()
    Remote:FireServer(script.Parent.Parent.PlayerName.Text,script.Parent.Parent.Award.Text)
end

script.Parent.MouseButton1Click:Connect(ButtonPress)

Server

--ServerScript

local Remote = game:GetService('ReplicatedStorage'):WaitForChild('award')

function Reward(Player,Name,awardd)
game.Workspace.Screen.MainScreen.SurfaceGui.StartPage.Visible = false
game.Workspace.Screen.MainScreen.SurfaceGui.Award.Visible = true
game.Workspace.Screen.MainScreen.SurfaceGui.Award.TextLabel.Text = "Congratulations, "..Name.." you have won the "..awardd
end

Remote.OnServerEvent:Connect(Reward)

Ad
Log in to vote
0
Answered by 5 years ago

remove one d in rewardd, you connected reward but you use rewardd

0
that doesnt fix it LEWIS1063 6 — 5y
Log in to vote
-1
Answered by 5 years ago

When you fire a remoteevent to the server, it carries the client it was fired from with it. For instance.

:FireServer()

OnServerEvent:Connect(function(player)

On the server script, player is a player instance, and awardd is the players name. You're getting the error because you're trying to concatenate a player object with a string. Use the following code in your server script:

local remote = game.ReplicatedStorage.award

remote.OnServerEvent:Connect(function(plr, player, awardd)
    game.Workspace.Screen.MainScreen.SurfaceGui.StartPage.Visible = false
    game.Workspace.Screen.MainScreen.SurfaceGui.Award.Visible = true
    game.Workspace.Screen.MainScreen.SurfaceGui.Award.TextLabel.Text = "Congratulations, "..player.." you have won the "..awardd
    print(player, awardd)
end)
0
Tried that, it doesnt work error: attempt to concatenate local 'awardd' (a nil value) LEWIS1063 6 — 5y
0
you are still using wrong functions Gameplayer365247v2 1055 — 5y

Answer this question