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

only working in test server with one player?

Asked by 9 years ago

Hi I have been scripting this with some help and when I went to play with my friends the text button didn't work for anyone. It only worked in the test server with one player. Can you help?

plr = game.Players.LocalPlayer
price = 550
debounce = false

script.Parent.MouseButton1Click:connect(function()
   if debounce then return end 
    local v = plr.leaderstats.Credits
    debounce = true 
    if v.Value >= price then
        plr.Backpack.ClassicSword.Configurations.LungeDamage.Value = 50
        v.Value = v.Value - price
        script.Parent.Parent.Buy.Visible = true
        wait(0.2) 

        for i = 0.1,1,0.1 do
            wait(0.1)
            script.Parent.Parent.Buy.TextTransparency = i
        end

        script.Parent.Active = false
        script.Parent.Visible = false
        script.Parent.Parent.upgrade2.Active = true
        script.Parent.Parent.upgrade2.Visible = true
        script.Parent.Parent.error.Position = UDim2.new(0, 200, 0, 100)
        script.Parent.Parent.Buy.Position = UDim2.new(0, 200, 0, 100)

        print('You bought the item!')
    else 
    print ('Cant buy item!')
        script.Parent.Parent.error.Visible = true

        for i = 0.1,1,0.1 do -- from 0.1 to 1 with 0.1 increments
            wait(0.1)
            script.Parent.Parent.error.TextTransparency = i
        end
    end
debounce = false
end)

0
Is it part of a SurfaceGui or is it in the player? 1waffle1 2908 — 9y
0
player docrobloxman52 407 — 9y
0
actually someone answered this and when I tried yours my text didn't fade but the cool down worked, any way could you help with this since you are a pretty good scripter with all your games (I love) so could you help? https://scriptinghelpers.org/questions/20199/upgrades-saving-when-dying-and-make-the-upgrades-you-have-already-inactive-and-invisible docrobloxman52 407 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago
--Instead use server sided PlayerAdded event
price = 550
debounce = false
game.Players.PlayerAdded:connect(function(plr)--This event will handle multiple players in your game if you wanna stick to local use the ChildAdded event.
script.Parent.MouseButton1Click:connect(function()
   if debounce then return end 
    local v = plr.leaderstats.Credits
    debounce = true 
    if v.Value >= price then
        plr.Backpack.ClassicSword.Configurations.LungeDamage.Value = 50
        v.Value = v.Value - price
        script.Parent.Parent.Buy.Visible = true
        wait(0.2) 

        for i = 0.1,1,0.1 do
            wait(0.1)
            script.Parent.Parent.Buy.TextTransparency = i
        end

        script.Parent.Active = false
        script.Parent.Visible = false
        script.Parent.Parent.upgrade2.Active = true
        script.Parent.Parent.upgrade2.Visible = true
        script.Parent.Parent.error.Position = UDim2.new(0, 200, 0, 100)
        script.Parent.Parent.Buy.Position = UDim2.new(0, 200, 0, 100)

        print('You bought the item!')
    else 
    print ('Cant buy item!')
        script.Parent.Parent.error.Visible = true

        for i = 0.1,1,0.1 do -- from 0.1 to 1 with 0.1 increments
            wait(0.1)
            script.Parent.Parent.error.TextTransparency = i
        end
    end
debounce = false
end)
end)

If this helped which I hope it did be sure to upvote or accept.

0
didnt work any ideas? docrobloxman52 407 — 9y
Ad

Answer this question