Hello! I am making it so that when you buy the boat, you do not have to rebuy it after leaving and rejoining. My script is as below:
Place where it should deduct cash and save the fact that the person bought it
ProxyPromote.Triggered:Connect(function(plr)
local HasMotorBoat = plr.HasMotorBoatStats.HasMotorBoat
local Cash = plr.leaderstats.Cash
if plr and ProxyPromote.Enabled then
if HasMotorBoat.Value == 1 then
Sit(plr.Character.Humanoid)
else
Sit(plr.Character.Humanoid)
Cash.Value = Cash.Value - 1000
print("datastore works hmm")
HasMotorBoat.Value = 1
end
end
end)
```lua
local DataStoreService = game:GetService("DataStoreService")
local HasMotorBoat = DataStoreService:GetDataStore("HasMotorboat")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local UserId = Player.UserId
local Currency = HasMotorBoat:GetAsync(UserId)
local HasMotorBoatStats = Instance.new("Folder", Player)
HasMotorBoatStats.Name = "HasMotorBoatStats"
if not HasMotorBoatStats == 1 then
HasMotorBoatStats = 0
print("oh this is why...")
end
local HasMotorBoat = Instance.new("IntValue", HasMotorBoatStats)
HasMotorBoat.Name = "HasMotorBoat"
HasMotorBoat.Value = Currency
HasMotorBoat.Changed:Connect(function(NewValue)
HasMotorBoat:SetAsync(UserId, NewValue)
end)
end)
(Where I try to save it) However, I get this error:
SetAsync is not a valid member of IntValue “Players.nicknickphoenix.HasMotorBoatStats.HasMotorBoat”
The error is from this line:
HasMotorBoat:SetAsync(UserId, NewValue)
I’ve tried searching this error up, but I couldn’t find anything.