I need help debugging a tool

So what am I supposed to change?
event:FireServer(mouse.Hit.Position) This?
event.OnServerEvent:Connect(function(player, pos) bone:Clone() or this?

The first one only seems to work, while the 2nd one looks like it has to do with the wording for (player,pos).

If the event position has to do with the problem, tell me where to put it. If not, tell me what I need to change, because I do not know what to do and I’m not that experienced at all.

Well, since that function runs every time you click the tool, you’ll want to put event:FireServer(mouse.Hit.Position) there.

Where should I put it? In the server script or the local script at the end of the function?

1 Like

The LocalScript function, should’ve been more clear about that. You can’t call FireServer on a server script, btw.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local bone = script.Parent.BoneSmash
local gs = game:GetService("ReplicatedStorage")
local event = gs.RemoteEvent

script.Parent.Activated:Connect(function()
	if mouse.Button1Down then
		print(script.Parent:GetChildren())
		local g = bone:Clone() 
		print("SENDING")
		g.Parent = workspace
		g.Script.Enabled = true
		g.Position = mouse.Hit.Position + Vector3.new(0,80,0)
		task.wait(0)-- Fire rate
	end
end)

event:FireServer(mouse.Hit.Position)

This is my current code so far. Unless I had done something wrong, the same thing happened when I ran the game as I’ve said before.

Currently you’re only firing the server one time when the script starts. You need to move it to the function connected to activating your tool to make it fire when you use the tool.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local bone = script.Parent.BoneSmash
local gs = game:GetService("ReplicatedStorage")
local event = gs.RemoteEvent

script.Parent.Activated:Connect(function()
	if mouse.Button1Down then
		print(script.Parent:GetChildren())
		local g = bone:Clone() 
		print("SENDING")
		g.Parent = workspace
		g.Script.Enabled = true
		g.Position = mouse.Hit.Position + Vector3.new(0,80,0)
		task.wait(0)-- Fire rate
	end
	event:FireServer(mouse.Hit.Position)
end)

Tried this as well, but it doesn’t look like it changed anything either. Am I supposed to change the function at the start to connect with the tool, then modify event:FireServer(mouse.Hit.Position) to connect to the 2nd script? If not, tell me how am I supposed to do it, as I am in doubt of doing many things, such as creating another event assiociated with the server and renaming the functions to support a local tool = blah blah blah, etc.

Weird, could you add a print statement after that line and see if that prints? Also, the if mouse.Button1Down line is basically useless since it will always return true. Button1Down is an event, not a boolean, so you’re basically checking if the event exists.

If you are talking about event:FireServer(mouse.Hit.Position), when I put a print statement afterwards it did print but the remoteEvent, as I’ve said before, pretty self explanatory at this point. What I wanted didn’t happen.

So from what I can gather the event isn’t running at all… Are there any errors in output, or in the server script handling the event?

There is no errors happening either. It might have to do with this line of code, event.OnServerEvent:Connect(function(player, pos) bone:Clone(). The server script is handling what the bone smash does after that point.

Yep, I know it’s handling that. The thing is, I don’t see anything that would cause it to not run. Do you mind sending a full screenshot of your output? From what I can tell it should be working.

As demonstrated in this video, the print for the start of the serverScript, print("Started") Does not show at all.

Is the script handling the RemoteEvent disabled by any chance?

Yes, from the very start when I showed the script heriarchy, the server script was intentionally disabled and enabled upon the localscript being triggered.

Yep :grimacing: just noticed the issue. Upset with myself for not noticing it before but I just did.
You’re enabling the script on the client. That doesn’t change anything since a server script is… well, a server script. Enabling it on a single client does nothing. Why does the script start as disabled in the first place?

Tried it without enabling. The script worked, however the original bone (The bone used to replicate more bones) will perform the script instead of the duplicated ones. That was the reason why I wanted it disabled and enabled in the first place.

You could try putting the bone in ReplicatedStorage instead

Did that. Same thing happens, the duplicated bones now with the script don’t perform what I want.

Can you send your current scripts? I think I know the problem but I just want to make sure.