I need help debugging a tool

can you check in the bones if the script gets enabled as in check if enabled is true

I ran in the workspace. I equipped the tool, clicked on where I want the bone to spawn, checked the Bone Smash, script is enabled but doesn’t fire off.

localscripts dont run in the workspace and if its a serverscript you need to communicate to the server to create it otherwise it will only exist for you and not work

So then, what should I do? I changed the first script to a server script. I do not know what to write now.

The script inside bone needs to be a server script. Now you could tell the server through a remoteevent to clone the attack so it get replicated to everyone.

As I’ve said, I am not sure on how to write a remoteEvent for tools, nor be able to apply the knowledge of remoteEvents. This is what I have so far.

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

tool.Equipped:Connect(function(mouse)
	mouse.Button1Down:Connect(function() 
		if mouse.Hit.Position then
			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)
end)

event:FireAllClients()
event.OnServerEvent:Connect(boneSmashSpin)
local boneSmash = script.Parent
local getPosition = boneSmash.CFrame
local sound = boneSmash["Undertale  Notice"]
local gs = game:GetService("ReplicatedStorage")
local event = gs.RemoteEvent

function boneSmashSpin()
	print("Started")
	boneSmash.Transparency = 0
	for i = 1,7 do
		boneSmash.Position = boneSmash.Position + Vector3.new(0,1,0)
		task.wait(0.06)
	end
	sound:Play()
	task.wait(0.65)
	for i = 1,8 do
		boneSmash.Position = boneSmash.Position + Vector3.new(0,-10,0)
		task.wait(0.06)
	end
	local explosion = game.ServerStorage.Explosion:clone()
	explosion.Position = boneSmash.CFrame.Position + Vector3.new (0,-25,0)
	explosion.Parent = workspace
	explosion.KillScript.Enabled = true
	explosion.Script.Enabled = true
	for i = 1,15 do
		boneSmash.Position = boneSmash.Position + Vector3.new(0,-1,0)
		boneSmash.Transparency = i / 15
		task.wait(0.05)
	end
	boneSmash.CFrame = getPosition
	task.wait(0.05)
	script.Parent:Destroy()
end

event.OnServerEvent:Connect(mouse)

For context, I do not know how to interconnect the scripts through remoteEvents, know what exactly I need to write and how to debug the script.

2 Likes

local remote = --Wherever you decide to put the instance

then in the tool local script you do

remote:FireServer(mouse.Hit.Position)

In another serverscript inside the tool you do

remote.OnServerEvent:Connect(function(player, pos) bone:Clone() --do all the copy stuffff end)

1 Like

Do I have to create another local script and another serverScript to do that?

1 Like

No you don’t, you can just replace what you have right now.

1 Like

What am I supposed to copy? The 2nd script’s boneSmashSpin function’s insides? I need elaboration.

1 Like

Can you print script.Parent:GetChildren() and see what happens? That’s super weird.

1 Like

Where exactly do I write it? This is my current code so far.

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
		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)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local bone = script.Parent.BoneSmash
local gs = game:GetService("ReplicatedStorage")
local event = gs.RemoteEvent
local boneSmash = script.Parent
local getPosition = boneSmash.CFrame
local sound = boneSmash["Undertale  Notice"]


event.OnServerEvent:Connect(function(player, pos) bone:Clone()
	print("Started")
	boneSmash.Transparency = 0
	for i = 1,7 do
		boneSmash.Position = boneSmash.Position + Vector3.new(0,1,0)
		task.wait(0.06)
	end
	sound:Play()
	task.wait(0.65)
	for i = 1,8 do
		boneSmash.Position = boneSmash.Position + Vector3.new(0,-10,0)
		task.wait(0.06)
	end
	local explosion = game.ServerStorage.Explosion:clone()
	explosion.Position = boneSmash.CFrame.Position + Vector3.new (0,-25,0)
	explosion.Parent = workspace
	explosion.KillScript.Enabled = true
	explosion.Script.Enabled = true
	for i = 1,15 do
		boneSmash.Position = boneSmash.Position + Vector3.new(0,-1,0)
		boneSmash.Transparency = i / 15
		task.wait(0.05)
	end
	boneSmash.CFrame = getPosition
	task.wait(0.05)
	script.Parent:Destroy()
end)

When I run workspace, the same thing happens. Bone appears locally, doesn’t run its function, doesn’t clone itself for the server to see and doesn’t do its function at all.

2 Likes

Oh, the code has changed a lot since the original post. I hadn’t read the other replies. Print it right before the bone:Clone() line as I assume that’s still not working?

Tried it for the localScript. It printed this.

{
                    [1] = BoneSmash,
                    [2] = LocalScript
  }

For the serverScript, it shows nothing as said in other replies. The serverScript even when called by a remoteEvent does not fire off and do it’s job as stated,

When I run workspace, the same thing happens. Bone appears locally, doesn’t run its function, doesn’t clone itself for the server to see and doesn’t do its function at all.

1 Like

Oh, so the original error is fixed. That’s great! What do you mean by “run workspace”? From what I’m gathering you’re saying that the RemoteEvent doesn’t trigger.

What I mean by “run workspace” is pressing play on Roblox Studio to enter the game. The only reason why this post is not completed is because there was a 2nd issue that prevented what I wanted, being a bone smash occuring when you clicked on a certain location not triggering.

1 Like

In other words, I will have to repeat what I’m trying to make again.

I’m trying to make a bone smash attack that the local script will spawn a bone at the player’s mouse location, which the bone will do what I put (go up, go down rapidly, create a explosion and then destroy itself).

Now, I’m not sure about the serverStorage part (the explosion) if it will appear for the server, however the main issue as of right now is currently the remoteEvent not triggering the 2nd serverScript to fire it’s action.

Well currently your code fires the server once and never again. I assume you would want to put that in the function so it fires when you use the tool, right?

Yes. I want it so that when I equip the tool, press mouse 1 on wherever I want it to be, it spawns a bone smash for the server to see and I can do it repeatably.

Yeah, I assumed. That’s why I said

because currently that’s not what you’re doing.

1 Like