I have two instances where it would work, but once I do something, it wouldn't work. It's basketball-related again, lol. I'll show you 2 GIFs and show you the reasons why the script breaks. The script will be down below.

local debounce = false
local players = game:FindService("Players") 

script.Parent.Touched:connect(function(hit)
    if debounce then
        return
    end

    debounce = true

    if hit.Name == "Handle" and hit.Parent:IsA("Tool") then
        local Ball = hit
        local BallHandlerVal = Ball.Parent:WaitForChild("BallHandler") 
        local BallHandler = players:FindFirstChild(BallHandlerVal.Value) -- 
        local cash = BallHandler:FindFirstChild("leaderstats")
        if BallHandler and cash then 
            local EXPValue = cash:WaitForChild('XP')
            if BallHandler:IsInGroup(3164314) then
                EXPValue.Value = EXPValue.Value + 10 
                print("Gave +10 EXP")
            else
                EXPValue.Value = EXPValue.Value + 5 
                print("Gave +5 EXP")
            end
        end
    wait(1)
    debounce = false
    end
end)

GIF to show you how it works:

GIF #1

GIF to show you how it breaks:

GIF #2

Here is the Dunking Script if you were interested.

hoop=script.Parent.Parent.Parent.Parent
player=script.player
brick=script.Parent

function Dunking(hit)
	local person=hit.Parent
	if person.ClassName=="Accessory" then
		wait()
	elseif person:findFirstChild("Humanoid"and"Torso") then	
		if hit.Name==("Left Arm" or "Right Arm") then
			player.Value=person.Name
			v=person:GetChildren()
			for i=1,#v do
				if v[i].ClassName=="Tool" then
					script.Disabled=true
					person.Head.Anchored=true
					local ball=v[i]
					ball.Parent=workspace
					ball.Handle.Position=hoop.Backboard.here.Position
					local d=brick.dunk:Clone()
					d.Parent=ball
					d.Script.Disabled=false
				end
			end
			wait(1)
			v=game.Players:GetChildren()
			for i=1,#v do
				if v[i].Name==player.Value then
					v[i].Character.Head.Anchored=false
				end
			end
			wait(1.5)
			hoop.Head.GUI.Label.Text=""
		end
	end
	script.Disabled=false
end

brick.Touched:connect(Dunking)

Thanks for all the help!

LukeGabrieI aka EnergyBrickz

3 comments

0

Both Gif's are the same...

0

oops ill fix that

0

So what you need to figure out is where exactly the script stops working. To do that, you need to spam the thing with prints. Is the touched event even firing?