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

I've been trying to fix this for 30 minutes... Any way to fix this script?[EDITED]

Asked by 8 years ago
Edited 8 years ago

Here's the script:

01player = game.Players.LocalPlayer
02Bought = script.Parent.Bought
03Bought.Value = false
04 
05local HireCost = Instance.new("IntValue")
06HireCost.Parent = player
07HireCost.Value = 10
08 
09script.Parent.MouseButton1Click:connect(function(Building)
10    local leaderstats = player:FindFirstChild("leaderstats")
11    local mg = script.Parent:WaitForChild("HireMoney")
12    if leaderstats.Cash.Value >= HireCost.Value then
13         player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - HireCost.Value
14        if Bought.Value == false then
15            Bought.Value = true
View all 21 lines...

There is also another script in the button:

01while true do
02    local player = game.Players.LocalPlayer
03    Bought = script.Parent.Bought
04    local mg = script.Parent:WaitForChild("HireMoney")
05    wait(0.5)
06    if Bought.Value == true then
07        player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + mg.Value
08    elseif Bought.Value == false then
09    --Nothing Should Happen If It Has Not Been Bought
10    end
11end

It works perfectly in studio, but doesn't work in-game.This is a Local Script. Please fix this. Thanks!

0
Is your game FE? User#5423 17 — 8y
0
No SmxkePurpp 50 — 8y

1 answer

Log in to vote
0
Answered by
nanaluk01 247 Moderation Voter
8 years ago
Edited 8 years ago

You could try to see if this works:

01player = game.Players.LocalPlayer
02Bought = script.Parent.Bought
03Bought.Value = false
04 
05local HireCost = Instance.new("IntValue")
06HireCost.Parent = player
07HireCost.Value = 10
08 
09script.Parent.MouseButton1Click:connect(function(Building)
10    local leaderstats = player:FindFirstChild("leaderstats")
11    local mg = script.Parent:WaitForChild("HireMoney")
12    if leaderstats.Cash.Value >= HireCost.Value then
13        if Bought.Value == false then
14            Bought.Value = true
15            HireCost.Value = HireCost.Value*2
16            mg.Value = mg.Value + 1
17        end
18        player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - HireCost.Value
19    end
20end)

And Put This Into Another localscript with the same parent as you other script:

01while true do
02    local player = game.Players.LocalPlayer
03    Bought = script.Parent.Bought
04    local mg = script.Parent:WaitForChild("HireMoney")
05    wait(0.5)
06    if Bought.Value == true then
07        player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + mg.Value
08    end
09    elseif Bought.Value == false then
10    --Nothing Should Happen If It Has Not Been Bought
11    end
12end
0
Still will not work. SmxkePurpp 50 — 8y
0
Remember to explain what you are doing differently, that way the OP can understand what your code does compared to his. shayner32 478 — 8y
0
Fixed an error in your script. The errors were: if leaderstats.Cash.Value >= HireCost then, it supposed to be if leaderstats.Cash.Value >= HireCost.Value then second error: player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - HireCost, supposed to be player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - HireCost.Value SmxkePurpp 50 — 8y
0
But it works. Only in studio, not in-game. SmxkePurpp 50 — 8y
0
Try it in-game, and if it does not work, open the developer console and look for errors. Then fix the errors. nanaluk01 247 — 8y
Ad

Answer this question