Gain power when clicking the screen

Hi to everyone, this code what ı used. This cod this code is not complete yet there are a few aspects I would change but the thing that made me open this topic is this code is a code inside the mousebutton, when the user clicked is imagelabel this cod gives the user jumppower as u can see. I don’t want to use imagelabel anymore becayse ı want to make it look more original, I want the players to gain this effect when they click directly on the SCREEN, this is very important to me.

local plr = game.Players.LocalPlayer
local char = plr.Character

local debounce = false

-- JumpPower değerindeki değişiklikleri takip eden fonksiyon
local function onJumpPowerChanged(newValue)
	char.Humanoid.JumpPower = newValue
end

-- JumpPower değeri değiştiğinde onJumpPowerChanged fonksiyonunu çalıştıran fonksiyon
plr.leaderstats.JumpPower.Changed:Connect(onJumpPowerChanged)

script.Parent.Activated:Connect(function()
	if debounce == false then
		debounce = true
		if plr.leaderstats.Rebirths.Value == 0 then
			plr.leaderstats.JumpPower.Value += 1
		end

		if plr.leaderstats.Rebirths.Value == 1 then
			plr.leaderstats.JumpPower.Value += 10
		end

		if plr.leaderstats.Rebirths.Value == 2 then    
			plr.leaderstats.JumpPower.Value += 20
		end

		if plr.leaderstats.Rebirths.Value == 3 then    
			plr.leaderstats.JumpPower.Value += 30
		end        

		if plr.leaderstats.Rebirths.Value == 4 then            
			plr.leaderstats.JumpPower.Value += 40      
		end

		debounce = false
	end
end)

Try this.

local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()

local debounce = false

-- JumpPower değerindeki değişiklikleri takip eden fonksiyon

local function onClick()
    if debounce == false then
		debounce = true
		if plr.leaderstats.Rebirths.Value == 0 then
			plr.leaderstats.JumpPower.Value += 1
		end

		if plr.leaderstats.Rebirths.Value == 1 then
			plr.leaderstats.JumpPower.Value += 10
		end

		if plr.leaderstats.Rebirths.Value == 2 then    
			plr.leaderstats.JumpPower.Value += 20
		end

		if plr.leaderstats.Rebirths.Value == 3 then    
			plr.leaderstats.JumpPower.Value += 30
		end        

		if plr.leaderstats.Rebirths.Value == 4 then            
			plr.leaderstats.JumpPower.Value += 40      
		end

		debounce = false
	end
end

local function onJumpPowerChanged(newValue)
	char.Humanoid.JumpPower = newValue
end

-- JumpPower değeri değiştiğinde onJumpPowerChanged fonksiyonunu çalıştıran fonksiyon
plr.leaderstats.JumpPower.Changed:Connect(onJumpPowerChanged)

script.Parent.Activated:Connect(function()
	onClick()
end)

mouse.Button1Down:Connect(function()
    onClick()
end)
1 Like

thank you very much sir… ı am grateful

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.