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: 
LocalScript (although it doesnt break)
local tool = script.Parent
local re = tool: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 = tool:WaitForChild("BallRE")
local first_time = true
local cooldown = false
local ps = game:GetService("PhysicsService")
if first_time == true then
first_time = false
ps:CreateCollisionGroup("Ball")
ps:CreateCollisionGroup("Character")
ps:CollisionGroupSetCollidable("Character", "Ball", false)
end
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)
I moved the remote event to replicated storage but it still doesn’t work after I reset
Is there some sort of error printing in the output or does it stop at a certain line?
there are no errors or anything in the output when you reset or don’t it just doesn’t do anything after you reset
Have you checked at what part it breaks if so please?
what do you mean the regular script breaks after you reset I tested this bc I used a print statement in the beginning of each script and the local script didnt break after resetting but the regular script wasn’t printing anything after I reset
When you reset, first_time = true
since its a server script inside a tool. This means every time you reset, you are trying to create a new collision group each time. If you put the server script inside ServerScriptService, it should work.
You will probably need to switch your debounce system to something like this
local debounce = {}
if table.find(plr.Name,debounce) == nil then
table.insert(plr.Name,debounce)
wait(debounceTime)
debounce[plr.Name] == nil
end```
so I would have to add a debounce system because I don’t think I have one already and also how would it work in serverscriptservice because the tool gets cloned in the backpack so shouldn’t it be inside the tool
You could either pass the tool through the remote and check it on the server, or you could define the tool on the server, example:
Example 1:
-- Local
re:FireServer(mouse.Hit,tool)
-- Server
re.OnServerEvent:Connect(function(plr, mouseHit,tool)
if tool.Parent == plr.Character
end
end)
Example 2:
re.OnServerEvent:Connect(function(plr, mouseHit)
local tool = plr.Character:FindFirstChildOfClass("Tool") -- gets the tool
if tool then
end
end)
This it’s probably caused because you’re indexing an old instance that does not exist anymore, this it’s common when you reset.
1 Like
what instance 38383281848u324852u348328uruf84j3e