Script doesn't work after resetting

In serverstorage i have a beach ball with 2 scripts inside and by using print statements im pretty sure the localscript doesnt break but the other regular script isnt working after resetting. The ball gets cloned and put in the backpack and startergear when you purchase it with a GUI.
Explorer: Screen Shot 2021-09-02 at 12.29.16 PM
LocalScript (although it doesnt break)

local tool = script.Parent
local re = game.ReplicatedStorage:WaitForChild("BallRE")


local mouse = game.Players.LocalPlayer:GetMouse()


tool.Activated:Connect(function()
	
	re:FireServer(mouse.Hit)
end)

Server script (The one that breaks)

local tool = script.Parent
local re = game.ReplicatedStorage:WaitForChild("BallRE")

local cooldown = false


local ps = game:GetService("PhysicsService")
ps:CreateCollisionGroup("Ball")
ps:CreateCollisionGroup("Character")
ps:CollisionGroupSetCollidable("Character", "Ball", false)


re.OnServerEvent:Connect(function(plr, mouseHit)

	local char = plr.Character
	local hum = char:FindFirstChild("Humanoid")


	if hum and not cooldown then

		cooldown = true

		hum.Jump = true

		local ballClone = tool.Handle:Clone()
		ballClone.Transparency = 0
		tool.Handle.Transparency = 1


		for i, descendant in pairs(plr.Character:GetDescendants()) do
			if descendant:IsA("BasePart") then ps:SetPartCollisionGroup(descendant, "Character") end
		end
		ps:SetPartCollisionGroup(ballClone, "Ball")


		local velocity = mouseHit.Position + Vector3.new(0, game.Workspace.Gravity * 0.5, 0)
		ballClone.Velocity = velocity

		ballClone.CanCollide = true
		ballClone.Parent = workspace


		game:GetService("Debris"):AddItem(ballClone, 2)

		wait(3)
		ballClone.Velocity = Vector3.new(0, 0, 0)
		tool.Handle.Transparency = 0
		cooldown = false
	end
end)

Instead of not cooldown, you will wanna put:

and Cooldown ~= true then

or:


and Cooldown == false then

1 Like

The ball still shoots but when I reset I have the same problem with it not doing anything

1 Like

First thing I notice about this is that on your localscript, your firing the event in the tool, but on your serverscript, waiting for input from a event form replicated storage???

1 Like

oh oops that was a different script the one im using is game.ReplicatedStorage not tool

I think it may be breaking because you keep creating collision groups everytime the tool is spawned

1 Like

so should I only be doing that once?

Yea you can only do one collision group with one name. Copy and paste the code where you make the groups into a server script service script

Also just wondering, have you checked the ouput?

yea there arent any errors though

have you tried this yet??? It should work if you try it ( I think)

1 Like

if I put local ps = game:GetService("PhysicsService") ps:CreateCollisionGroup("Ball") ps:CreateCollisionGroup("Character") ps:CollisionGroupSetCollidable("Character", "Ball", false) into a server script then what about the part of the script that goes for i, descendant in pairs(plr.Character:GetDescendants()) do if descendant:IsA("BasePart") then ps:SetPartCollisionGroup(descendant, "Character") end end ps:SetPartCollisionGroup(ballClone, "Ball")

You would just get hte physics service and thats it

1 Like

but then what about the variables throughout the script

or should I leave them in that script and also put them in a server script

You don’t make any variables. The only thing you are doing in the serverscript is creating the collisions


so like a server script with this and then do i keep that in the other script too?

1 Like

no you delete everything from those four lines except for the one where you do the game:GetService()

1 Like

ok I delete the lines in the tool script or the server one

you delete it from the tool script

1 Like