Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why wont this work?!! Your help would be greatly appreciated! (SOLVED)

So I did the fallowing code, and put it inside a tree and made it so that every player spawns with a "AxSpeed" Value within there Character, and I tryed it out but it wont work for some reason... can someone help me?


script.Parent.MouseClick:connect(function(player)
local AxSpeed = player.Character.AxSpeed.Value
player.Character.Torso.Anchored = true
 wait(AxSpeed)
Tree.Trunk.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
Tree.Foliage1.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
Tree.Foliage2.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
Tree.Foliage3.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
Tree.Foliage4.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
wait(1)
-- I dont cair if the tree wont be on the ground... I can work on the cframe later...
Tree.Foliage1.Anchored = false
Tree.Foliage2.Anchored = false
Tree.Foliage3.Anchored = false
Tree.Foliage4.Anchored = false
Tree.Trunk.Anchored = false
Tree:remove()
player.Character.Torso.Anchored = false
end)

Tree = script.Parent.Parent

Thank you

2 answers

✓ Accepted answer

You have to use a ClickDetector. Define Tree at the top of your code. Use Destroy() instead of Remove(), Remove() is outdated.

--Assuming there is a click detector in the trunk of the tree
--Assuming the script is in the trunk of the tree

Tree = script.Parent.Parent

script.Parent.ClickDetector.MouseClick:connect(function(player)
local AxSpeed = player.Character.AxSpeed.Value
player.Character.Torso.Anchored = true
 wait(AxSpeed)
Tree.Trunk.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
Tree.Foliage1.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
Tree.Foliage2.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
Tree.Foliage3.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
Tree.Foliage4.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
wait(1)
Tree.Foliage1.Anchored = false
Tree.Foliage2.Anchored = false
Tree.Foliage3.Anchored = false
Tree.Foliage4.Anchored = false
Tree.Trunk.Anchored = false
Tree:Destroy()
player.Character.Torso.Anchored = false
end)

2 comments

0

Thank You! I had put a Click Detector, but I only used it to show that the item was clickable. This worked! Thanks again!

0

No problem.

Line 2, for your variable. Don't put ".Value" when defining a variable (I forgot the reason why e.e). When you put the wait(), make it wait(AxSpeed.Value)

2 comments

0

This only matters when you're assigning to the thing. In this case, he's not, so this is perfectly correct.

0

Thank you for your time, but its still not working ;(

This discussion is preserved as it was. New answers, comments, and votes are closed.