Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Okay, another question. This time, I need to know what is wrong with this script, anybody know how?.

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 :)

1 comment

0

automatically or on a touched brick or a button gui

1 answer

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.

2 comments

0

Okay thanks! It's meant to be a one player game so i dont really mind if the "other players" cant see it :)

0

No problem. Please accept my answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.