Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can someone fix my buy button script?

Asked by
Seraine 103
10 years ago

I have a house which you can buy in game, the first time you buy it everything works fine. But once you sold the house, it won't let you buy it again for some reason :L

Please help if you can...Thanks !

Buy house script:

01owned = script.Parent.Parent.Parent.Owned.Value
02 
03script.Parent.Touched:connect(function(hit)
04    player = game.Players:GetPlayerFromCharacter(hit.Parent)
05    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
06        if owned == false and player.Cash.Value >=1000 and player.HasHouse.Value == false then
07            player.Cash.Value = player.Cash.Value - 1000
08        clone = game.Lighting.House:clone()
09      clone.Parent = player.PlayerGui
10            player.HasHouse.Value = true
11            player.PlayerGui.House.Frame.House1.Visible = true -- From this line and below are the buttons for the House Gui, it lets you change the settings of the house you bought.
12            player.PlayerGui.House.Frame.lockhouse1.Visible = true
13            player.PlayerGui.House.Frame.lightson1.Visible = true
14            player.PlayerGui.House.Frame.curtainsclose1.Visible = true
15            player.PlayerGui.House.Frame.bathroom1.Visible = true
View all 25 lines...

Sell house script:

01function Click(mouse)
02plr=script.Parent.Parent.Parent.Parent.Parent
03 
04            game.Workspace.Housee1:remove() -- Housee1 is the name of House, since the house Gui and the House building is both named House(num) and both inside Lighting, I decided to name the building different.
05        clone = game.Lighting.Housee1:clone()
06 
07            clone.Parent = game.Workspace
08game.Workspace.Kitchen:remove()
09game.Workspace.Bedroom:remove()
10game.Workspace.Bathroom:remove()
11game.Workspace.LivingRoom:remove()
12 
13         plr.Cash.Value = plr.Cash.Value+500
14plr.PlayerGui.House:remove()
15plr.HasHouse.Value = false
View all 22 lines...

I use a Gui for in game currency by the way, not a leaderboard.

0
12 Hours still no answer? Seraine 103 — 10y

2 answers

Log in to vote
0
Answered by
TofuBytes 500 Moderation Voter
10 years ago

Well, I was searching through and I noticed that Bedroom, Bathroom, and LivingRoom are all inside of the workspace, instead of a certain model. If there are none of those inside the Workspace, then the script will not completely execute.

01function Click(mouse)
02plr=game.Players.LocalPlayer --This was also changed because it's a client mouse click.
03 
04            game.Workspace.Housee1:remove()
05        clone = game.Lighting.Housee1:clone()
06 
07            clone.Parent = game.Workspace
08    game.Workspace.Kitchen:remove() --These should be placed into the specific house
09game.Workspace.Bedroom:remove() --
10game.Workspace.Bathroom:remove() --
11game.Workspace.LivingRoom:remove() --
12 
13 
14plr.Cash.Value = plr.Cash.Value+500
15plr.PlayerGui.House:remove()
16plr.HasHouse.Value = false
17end
18 
19script.Parent.MouseButton1Down:connect(Click)
Ad
Log in to vote
-1
Answered by
wrenzh 65
10 years ago

In the Sell Script on line 15, you wrote plr.PlayerGui.House:remove(), and then in the Buy Script on line 11 you wrote player.PlayerGui.House.Frame.House1.Visible = true.

I suggest you don't destroy the GUI when the player sells the house so that they can buy a house again.

0
Sell house script: plr=script.Parent.Parent.Parent.Parent.Parent Seraine 103 — 10y

Answer this question