So when I was trying to make a car game in Roblox Studio, I watched the tutorial, and I double checked the script. But that’s until I realized there isn’t any errors in the output. I tried my best to fix it and the script still won’t work, I also tried WaitForChild() the script still doesn’t work
Here’s the code I tried…
local carparams = game.ReplicatedStorage:WaitForChild("CarPurchaseSystem"):WaitForChild("GetCarParams"):InvokeServer(script.Parent.Name)
local image = script.Parent:WaitForChild("CarImage")
local showpurchaseframe = script.Parent.Parent.Parent.Parent:WaitForChild("ShowPurchaseFrame")
script.Parent.CarName.Text = carparams.Name
script.Parent.Cost.Text = carparams.Cost
script.Parent.MouseButton1Click:Connect(function()
showpurchaseframe:Fire(carparams.Name,carparams.Cost,carparams.Power,script.Parent.CarImage)
end)
Script isn’t working because in the first line you are using remote function’s :InvokeServer() method. This method yields (pauses) the script until it gets a response from the server.
You said it was from the tutorial, so the tutorial should have another script that is server sided [regular script in SeverScriptService for example] which should have something like this
local carParams = game.ReplicatedStorage.CarPurchaseSystem.GetCarParams
carParams.OnServerInvoke = function(player, name)
--Some logic here
return {
Name = "Some name",
Cost = 123,
Power = 123
} -- I assumed the returned value structure based on the script You provided
end
Without any server-sided script that binds a function to that remote function [carParams.OnServerInvoke = function() end] the client script waits indefinetly for response that’s never gonna get.