local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local bone = script.Parent.BoneSmash
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)
For context, I’m trying to make a bone smash attack that the local script will spawn a bone at the player’s mouse location. It doesn’t work properly and instead shows a error at line 4, BoneSmash is not a valid member of Tool "Players.borenreef.Backpack.Bone Smash"
. I’ve even tried removing local bone = script.Parent.BoneSmash
and replacing local g = bone:Clone()
with local g = script.Parent.BoneSmash:Clone()
but then when I try and click on a location, no errors show up, nor the script fires and the bone appears.
I am too frustrated from my inability to be able to debug scripts properly and I have been trying to debug the script for a entire hour, thus I’m asking for help. If anyone would please help me, I’d appreciate it. Thanks!
2 Likes
Try setting the parent last. Sometimes it glitches out in my experience
I believe that doesn’t change anything. There is NO roblox script that sets for example, script.Example.Parent
the parent last. I tried it but the same thing happened, except the BoneSmash is visible.
1 Like
You believe it doesnt change anything or you tried it and It didnt do anything also you say the error is at line 4 but line 4 is empty
1 Like
I tried it with that script change and the problem was still line 3, which the same error occured, BoneSmash is not a valid member of LocalScript "Players.borenreef.Backpack.Bone Smash.LocalScript"
.
1 Like
I think maybe bonesmash doesnt load quick enough. Try using :WaitForChild()
local bone = script.Parent:WaitForChild("BoneSmash")
1 Like
also can you provide a screenshot of the instance hierarchy in the explorer?
1 Like
Tried using :WaitForChild. The bone appears with no errors but it doesn’t perform the function I wanted.
1 Like
whats the error or what does it do exactly?
1 Like
There is no error shown in the output with :WaitForChild. I have explained what I am trying to make from my original post so I will say it again. I’m trying to make a bone smash attack that the local script will spawn a bone at the player’s mouse location. The issue is, the bone is not duplicating itself to where the player mouse clicked on and instead doesn’t duplicate, perform it’s script as intended, etc.
1 Like
are there new instances of the bone being spawned into the workspace when you try it out?
1 Like
No, when I hold out the tool and click, the bone does not duplicate into the workspace and it has to do with the mouse function preventing it from happening.
1 Like
so the mouse function doesnt run
1 Like
Yes. That’s the main issue that needs to be fixed. I do not know why there’s no error, or why the bone is not duplicating in the workspace upon clicking with the tool activated.
1 Like
is RequiresHandle turned off in the tool?
1 Like
It wasn’t at first. I turned off RequiresHandle and the bones do duplicate in the workspace however they don’t perform the function I want them to do in the 2nd script.
1 Like
so this issue is fixed but now theres another issue?
1 Like
Yes and since the bone smash tool works with duplicating the bones, it appears that the 2nd script even after being Enabled
doesn’t run as intended.
local boneSmash = script.Parent
local getPosition = boneSmash.CFrame
local sound = boneSmash["Undertale Notice"]
function boneSmashSpin()
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
while true do
boneSmashSpin()
task.wait(0.01)
end
When I clicked on the tool, the bone smash did duplicate. However the 2nd script I showed doesn’t run even after being Enabled
.
first of all you dont have to do
task.wait(0.01)
just do
task.wait()
and second of all are there any errors? try printing to see if:
1 it even starts
2 if it starts where it stops
Task.wait(0.01) is there to prevent script exhaustion. The script does NOT print any errors, nor does it print any of my print('")
s in where I put.
And as I said, even after the script is Enabled
, it does not run.
1 Like