I'm working on a simulator and this is a script for a UpgradeGui. On line 7 is where the error is. If someone helps it would be really helpful!
Thanks, notreallysupernova
--[[ First, put a RemoteEvent in Replicated Storage before doing any of this.
]]
-- Client/Local Script:
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
script.Parent.MouseButton1Down:Connect(function()
remoteEvent:FireServer() -- This is the error
end)
-- Server/Normal Script:
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local OwnUpgrade = game.ReplicatedStorage.Stats.OwnMoreCars
local CarRespawn = game.ReplicatedStorage.Stats.CarRespawn
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("OwnMoreCarsSaver")
local players = game:GetService("Players")
players.PlayerAdded:connect(function(player)
OwnUpgrade.Value = ds1:GetAsync(player.UserId) or false
ds1:SetAsync(player.UserId, OwnUpgrade.Value)
end)
if OwnUpgrade.Value == true then
CarRespawn.Value = CarRespawn.Value - 1
OwnUpgrade.Value = true
print("Owned Upgrade")
script.Parent:Destroy()
end
local player = remoteEvent.OnServerEvent:Wait()
local leaderstats = player:WaitForChild("leaderstats",7)
local Money = leaderstats:WaitForChild("Money")
local price = 300
if Money.Value >= price then
Money.Value -= price
print("Purchased")
CarRespawn.Value = CarRespawn.Value - 1
OwnUpgrade.Value = true
ds1:SetAsync(player.UserId, OwnUpgrade.Value)
script.Parent:Destroy()
end
