I'd give a little more explanation but I'm a bit clueless on this one, my only idea is that maybe it lies in the two functions but I honestly have no clue. I'll explain a bit in detail what happens step by step

  1. Tool equipped and I click once, it heals the player all is well
  2. The wait timer starts (checked with a for loop that changed the name of the tool to be sure)
  3. The model randomly disappears but the scripts still work fine, I can still heal myself every 5 seconds

The other weird thing about this is that in F5 mode this works fine, the model doesn't disappear. It only disappears in a regular server. So maybe it's something to do with FE or Client to Server/vice versa

local player = game.Players.LocalPlayer
local playerMouse = player:GetMouse()
local debounce = true
local tool = script.Parent

tool.Equipped:connect(function()
	playerMouse.Button1Down:connect(function()
		local humanoid = player.Character:WaitForChild("Humanoid")
		if debounce == true then
			debounce = false
			if humanoid.Health < 100 then
				humanoid.Health = humanoid.Health + 25
				
				wait(5)
			end
	
		debounce = true
		end
	end)
	end)

Edit I just tested it with the server test option so I could check out more whats going on and it seems the entire model, except for the handle is being deleted(or sent to some random place in the game)

I think this might be at the fault of my weld script, it was a free modeled one I took from the some open source gun models. I'm going to try and make my own and see if that fixes it; here is the current weld code

local function weld(x, y)
	local newWeld = Instance.new("Weld")
	newWeld.Part0 = x
	newWeld.Part1 = y
	local CJ = CFrame.new(x.Position)
	local C0 = x.CFrame:inverse()* CJ
	local C1 = y.CFrame:inverse()* CJ
	newWeld.C0 = C0
	newWeld.C1 = C1
	newWeld.Parent = x
end

function weldParts(object)
	if object:IsA("BasePart") or object:IsA("UnionOperation") then
		weld(script.Parent.Handle, object)
		object.Anchored = false
	else
		for i, c in pairs(object:GetChildren()) do
			weldParts(c)
		end
	end
end

local function weldTool()
	weldParts(script.Parent)
end

script.Parent.Equipped:connect(weldTool)
script.Parent.Unequipped:connect(weldTool)
weldTool()

2 comments

0

Haven't tested this, but try and use a RemoteEvent if you're using FE.

0

I transferred the healing process to a server script in SSS and used a RemoteFunction. Once again, works fine in F5 mode but now it does not work what so ever in play mode(and still disappears)