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.
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)
Do I have to create another local script and another serverScript to do that?
No you donât, you can just replace what you have right now.
What am I supposed to copy? The 2nd scriptâs boneSmashSpin functionâs insides? I need elaboration.
Can you print script.Parent:GetChildren() and see what happens? Thatâs super weird.
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.
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.
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.
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.