But the thing is that in the local script, the string will always equal a number between 1 and 5 not matter what so I have no idea why it wont work.
Server Script;
local DiscordWebhook = "" -- Removed so I dont get raided (Will replace when testing)
local HTTPSservice = game:GetService("HttpService")
local Event = game.ReplicatedStorage.RatingSystem.Ratings
Event.OnServerEvent:Connect(function(Player, AirportRating, ServiceRating, AircraftRating, Suggestion)
local Data =
{
["content"] = "",
["embeds"] = {{
["title"] = Player.Name,
["description"] = "Ratings: Airport: "..AirportRating.."/5",
}}
}
Data = HTTPSservice:JSONEncode(Data)
HTTPSservice:PostAsync(DiscordWebhook, Data)
end)
Local Script;
local Event = game.ReplicatedStorage.RatingSystem.Ratings
local AirportRatingUi = script.Parent.AirportRating
local ServiceRatingUi = script.Parent.ServiceRating
local AircraftRatingUi = script.Parent.AircraftRating
local AirportRating = AirportRatingUi.Rating.Value
local ServiceRating = ServiceRatingUi.Rating.Value
local AircraftRating = AircraftRatingUi.Rating.Value
local Suggestion = script.Parent.Suggestion.Text
local submit = script.Parent.Submit
submit.MouseButton1Click:Connect(function(Player)
Event:FireServer(Player, AirportRating, ServiceRating, AircraftRating, Suggestion)
end)
you get the value of airportrating when the function first runs, it will never change and will always be empty. you should get the value on mouse button click
You’re referencing the values from at the start of the UI, not when they actually press submit. Change your script to this:
local Event = game.ReplicatedStorage.RatingSystem.Ratings
local AirportRatingUi = script.Parent.AirportRating
local ServiceRatingUi = script.Parent.ServiceRating
local AircraftRatingUi = script.Parent.AircraftRating
local AirportRating = AirportRatingUi.Rating
local ServiceRating = ServiceRatingUi.Rating
local AircraftRating = AircraftRatingUi.Rating
local Suggestion = script.Parent.Suggestion
local submit = script.Parent.Submit
submit.MouseButton1Click:Connect(function(Player)
Event:FireServer(Player, AirportRating.Value, ServiceRating.Value, AircraftRating.Value, Suggestion.Text)
end)
Oh, I just realized that you’re trying to get the player from a MouseButton1Click and sending it over to the server. You don’t have to send the player instance over, as the Server already knows who sent the event.
Change your local script to this:
local Event = game.ReplicatedStorage.RatingSystem.Ratings
local AirportRatingUi = script.Parent.AirportRating
local ServiceRatingUi = script.Parent.ServiceRating
local AircraftRatingUi = script.Parent.AircraftRating
local AirportRating = AirportRatingUi.Rating
local ServiceRating = ServiceRatingUi.Rating
local AircraftRating = AircraftRatingUi.Rating
local Suggestion = script.Parent.Suggestion
local submit = script.Parent.Submit
submit.MouseButton1Click:Connect(function()
Event:FireServer(AirportRating.Value, ServiceRating.Value, AircraftRating.Value, Suggestion.Text)
end)