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

Help! My output is "attempt to call nil value " instead of the players name?

Asked by 1 year ago
Edited 1 year ago

whenever in the game i execute the command it just says attempt to call a nil value (im making a store off a video https://www.youtube.com/watch?v=tbCHsxR1UWE&ab_channel 32:06)

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('BuyTool')

local function Buytool(player)
        print(player.Name)
    end 

remoteEvent.OnServerEvent:Connect()
0
Can you put it in a code block? You didn't put it properly. BoiBoi24T 63 — 1y
0
done King_Grevious 0 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

You forgot to put Buytool inside the parentheses of remoteEvent.OnServerEvent:Connect().

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild('BuyTool')

local function Buytool(player)
    print(player.Name)
end 

remoteEvent.OnServerEvent:Connect(Buytool)
0
THANK YOU SO MUCH King_Grevious 0 — 1y
Ad

Answer this question