local original = game.ServerStorage.BasicFamilyHome
local clone = original:Clone()
if game.Players.LocalPlayer.leaderstats.Money.Value >= game.ReplicatedStorage.StarterHousePrice.Value then
script.Parent.ReplicatedStorage.BoughtStarterHouse.Value = 1 clone.Parent = workspace print("Sucessfully loaded the starter house!")
else
script.Parent.ReplicatedStorage.BoughtStarterHouse.Value = 0 print("bruh no monei m8")
end
That is meant to clone a house in ServerStorage if the player's cash is 50 or above. I already defined how much it is by an intvalue in replicatedstorage. I'd like help, thx :)
Hello. A LocalScript
cannot access ServerStorage
as it is only for the server. Instead, use ReplicatedStorage
. Note that the house will only show up for the player not the rest of the server, so try using RemoteEvents
. Also, I used :WaitForChild()
on the player's leaderstats as LocalScripts
execute before ServerScripts
so the leaderstats might not be created yet. I also added a repeat wait() until
statement until the player's character and the game is loaded. Try this:
repeat wait() until game:IsLoaded() and game.Players.LocalPlayer.Character local original = game.ReplicatedStorage.BasicFamilyHome local clone = original:Clone() if game.Players.LocalPlayer:WaitForChild("leaderstats").Money.Value >= game.ReplicatedStorage.StarterHousePrice.Value then script.Parent.ReplicatedStorage.BoughtStarterHouse.Value = 1 clone.Parent = workspace print("Sucessfully loaded the starter house!") else script.Parent.ReplicatedStorage.BoughtStarterHouse.Value = 0 print("bruh no monei m8") end
Please accept this answer and upvote it if it helped.