Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
Dr_Doge 100
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
1
Answered by 9 years ago

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)
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! Dr_Doge 100 — 9y
0
No problem. aquathorn321 858 — 9y
Ad
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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)

0
This only matters when you're *assigning* to the thing. In this case, he's not, so this is perfectly correct. BlueTaslem 18071 — 9y
0
Thank you for your time, but its still not working ;( Dr_Doge 100 — 9y

Answer this question