Hello. I have looked for an answer in the forum and found many posts, but none of them actually solved my issue. I am trying to take the name of an instance and pass it to a server script through a remote event, but it is returning nil instead.
Here’s some of the code:
Client:
local button = script.Parent
local repstorage = game:GetService("ReplicatedStorage")
debounce = true
button.Activated:Connect(function(player)
if debounce == true then
debounce = false
local naim = button.Name -- change button's name
repstorage.WearArmor:FireServer(player, naim)
wait(0.1)
debounce = true
end
end)
Server:
local storage = game:GetService("ServerStorage")
local repstorage = game:GetService("ReplicatedStorage")
repstorage.WearArmor.OnServerEvent:Connect(function(player, naim)
local character = player.Character or player.CharacterAdded:Wait()
print(character.Name)
print(naim)
Rather than printing out the name, it is printing out “nil” and the rest of the script does not work because of that. I would like to know how to solve this.
On the server, the .OnServerEvent event automatically passes the player that sent the signal. Passing the player again on the client with the :FireServer() function will cause another player parameter to show up on the server end: