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

only working in test server with one player?

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)

3 comments

0

Is it part of a SurfaceGui or is it in the player?

0

player

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

1 answer

✓ Accepted answer
--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.

1 comment

0

didnt work any ideas?

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