Hello, devs! I am trying to make a part which when touched, sends a message with a Discord bot. The webhook works but it says that I am attempting to index nil with the value. I tried using WaitForChild() but it didn’t work either. Here is the script.
local httpservice = game:GetService("HttpService")
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local randomNum = math.random(1, 3)
local check = player.AnnounceCheck
if check.Value == 0 then
if randomNum == 1 then
local Data = {
["content"] = player.Name.." has beat Level 1! Congrats!"
}
Data = httpservice:JSONEncode(Data)
httpservice:PostAsync("Private link.", Data)
check.Value = 1
print("Sent!")
return player
end
if randomNum == 2 then
local Data = {
["content"] = player.Name.." has beat Level 1! Yay!"
}
Data = httpservice:JSONEncode(Data)
httpservice:PostAsync("Private link.", Data)
check.Value = 1
print("Sent!")
return player
end
if randomNum == 3 then
local Data = {
["content"] = player.Name.." has beat Level 1! Let's party!"
}
Data = httpservice:JSONEncode(Data)
httpservice:PostAsync("Private link.", Data)
check.Value = 1
print("Sent!")
return player
end
end
end)