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

wanna keep button touched so people dont need to dance on it canu help ?

Asked by 4 years ago

hey can someone help me i want it te keep touched it is for a button so people dont need to dance on the button ```lua Door = script.Parent local debounce = false

function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onTouched(hit) if debounce == false then local human = hit.Parent:findFirstChild("Humanoid") if (human == nil) then return end local player = getPlayer(human) debounce = true if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Cash") -- replace nani with the stat that is getting removed/subtracted. local ao = stats:findFirstChild("Multi") local a = stats:findFirstChild("Rebirths") local u = stats:findFirstChild("Ultra") local m = stats:findFirstChild("Mega") local p = stats:findFirstChild("Prestige") local o = stats:findFirstChild("Levelc") -- replace nani with the stat that is getting removed/subtracted. if sp == nil then return false end if ao == nil then return false end if (sp.Value >=50) then -- replace 100 with stat cost sp.Value = sp.Value - 50 o.Value = 0 print("Enough Money") ao.Value = ao.Value + 2a.Valuem.Value*p.Value -- the multiplier you want Door.BrickColor = BrickColor.new("Maroon") wait(0) Door.BrickColor = BrickColor.new("Maroon") debounce = false else debounce = false end end

end

connection = Door.Touched:connect(onTouched) ```

0
You should format the code again. We can't see anything in your code. Block_manvn 395 — 4y
0
dude put all your scripts in "Code Block". It looks messy... guest_20I8 266 — 4y
0
all your codes I mean guest_20I8 266 — 4y

1 answer

Log in to vote
0
Answered by
Infocus 144
4 years ago
Edited 4 years ago
local debounce = false -- This was missing. Made your code easier to see

function getPlayer(humanoid)
    local players = game.Players:children()

    for i = 1, #players do
        if players[i].Character.Humanoid == humanoid then
            return players[I]
        end
    end
    return nil
end--

function onTouched(hit)
    if debounce == false then
        local human = hit.Parent:findFirstChild("Humanoid")
        if (human == nil) then
            return 
        end
        --
        local player = getPlayer(human)
        debounce = true 
        if (player == nil) then
    return 
end

local stats = player:findFirstChild("leaderstats") 
local sp = stats:findFirstChild("Cash") -- replace nani with the stat that is getting removed/subtracted.
local ao = stats:findFirstChild("Multi")
local a = stats:findFirstChild("Rebirths")
local u = stats:findFirstChild("Ultra")
local m = stats:findFirstChild("Mega") 
local p = stats:findFirstChild("Prestige") 
local o = stats:findFirstChild("Levelc") -- replace nani with the stat that is getting removed/subtracted. 

if sp == nil then 
    return false
end--

if ao == nil then
    return false
end--

if (sp.Value >=50) then -- replace 100 with stat cost 
    sp.Value = sp.Value - 50 
    o.Value = 0 
    print("Enough Money") 
    ao.Value = ao.Value + 2
    a.Value = Value * p.Value -- the multiplier you want Door.BrickColor = BrickColor.new("Maroon") wait(0) Door.BrickColor = BrickColor.new("Maroon") debounce = false else debounce = false end end
end--

connection = Door.Touched:connect(onTouched)
0
I also fixed Line 49, if your script isn't working as intended, then its probably that line Infocus 144 — 4y
0
if i add this script then it is broken rohanspeeltgames 0 — 4y
0
Idk then, all I did was add a debounce that you didn't specify. Maybe ask the one that helped you make the script Infocus 144 — 4y
0
the guy dont know him self rohanspeeltgames 0 — 4y
Ad

Answer this question