I need help debugging a tool

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

script.Parent.Activated:Connect(function()
	print(script.Parent:GetChildren())
	local g = bone:Clone() 
	print("SENDING")
	g.Parent = workspace
	g.Position = mouse.Hit.Position + Vector3.new(0,80,0)
	task.wait(0)-- Fire rate
	event:FireServer(mouse.Hit.Position)
	print("FINISHED.")
end)
local player = game.Players.LocalPlayer
local bone = script.Parent
local gs = game:GetService("ReplicatedStorage")
local event = gs.RemoteEvent
local boneSmash = script.Parent
local getPosition = boneSmash.CFrame
local sound = boneSmash["Undertale  Notice"]

print(script.Parent:GetChildren())
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)
1 Like

Yep, another client-server networking thing I didn’t notice earlier. Instead of modifying the bone in any way on the client, have the server script handle the bones in entirety. You could move the server script out of the bone and into the tool itself and just replace all mentions of bones specific to that tool to a cloned bone similar to what was being done on the client.

1 Like

Tried it. This time, it only clones 1 and does that permanently.

local player = game.Players.LocalPlayer
local bone = script.Parent
local gs = game:GetService("ReplicatedStorage")
local event = gs.RemoteEvent
local boneSmash = gs.BoneSmash
local sound = boneSmash["Undertale  Notice"]

print(script.Parent:GetChildren())
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
	task.wait(0.05)
	boneSmash:Destroy()
end)

This is the current script so far. What should I change?

I almost forgot to mention, print("Started") does it the moment the player joins the game, which means that there may be something with the remoteEvent code.

From the looks of it you’re just modifying the instance of boneSmash in ReplicatedStorage.
What do you mean by “it only clones 1 and does that permanently”?

Could you send your current client script?
Sorry it’s taking so long to fix this I’m actually tired as heck and I’m trying my best lol.


The server script remains unchanged. The video already cut off but I can explain what happened. The explosion was displaced from the bone, meaning that there was still some unfinished work that needs to be fixed, either with the local script or serverscript.

1 Like

can you make a clip of it after pressing play so we can see the whole attack


I shouldn’t have to repeat myself again. I have yet to get the desired result I want. Even when someone else tried to help me (by making it a remote function), nobody has managed to give a proper solution so far on making a tool that spawns a server attack from the player’s cursor.

Ill give you the formula to make it.
from the local script - as soon as the player presses mouse1 you sent the server the position of his mouse with a remote event

from the server script - you get the position from the mouse and the player through the local script and spawn whatever you want to spawn there.

besides - this is your issue. We are here to help. You cannot condem us for not having given you what you want exactly after we tried.

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

script.Parent.Activated:Connect(function()
	print(script.Parent:GetChildren())
	print("SENDING")
	task.wait(0)-- Fire rate
	event:FireServer(mouse.Hit.Position)
	print("FINISHED.")
end)
local player = game.Players.LocalPlayer
local bone = script.Parent
local gs = game:GetService("ReplicatedStorage")
local event = gs.RemoteEvent
local boneSmash = gs.BoneSmash
local sound = boneSmash["Undertale  Notice"]

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

This is the best I managed to get so far. For the 2nd script, the bone now fully appears for the server and duplicate infinitely but it stays locked into a single position and I have yet been able to figure out how the player’s mouse position when they click, the bone that spawns will do it’s job at that location. The problem is, it has to do with this line of code, local playerPosition = event.OnServerEvent:Connect(player:GetMouse()) . I’m not sure how I should rewrite this line of code.

I apologize for my rudeness. It’s just that I haven’t managed to get a proper solution yet and I already feel burnt out from trying to make new scripts, as everytime I do it I always run into one scenario: asking for help, which I then hope that anybody that replies and offers me the best solution but it seems here I ran into what feels like a dead end, where I just can’t figure out what people are trying to tell me. It’s just tiring me out and demotivating me from scripting.

1 Like