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
10 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?

01script.Parent.MouseClick:connect(function(player)
02local AxSpeed = player.Character.AxSpeed.Value
03player.Character.Torso.Anchored = true
04 wait(AxSpeed)
05Tree.Trunk.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
06Tree.Foliage1.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
07Tree.Foliage2.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
08Tree.Foliage3.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
09Tree.Foliage4.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
10wait(1)
11-- I dont cair if the tree wont be on the ground... I can work on the cframe later...
12Tree.Foliage1.Anchored = false
13Tree.Foliage2.Anchored = false
14Tree.Foliage3.Anchored = false
15Tree.Foliage4.Anchored = false
View all 21 lines...

Thank you

2 answers

Log in to vote
1
Answered by 10 years ago

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

01--Assuming there is a click detector in the trunk of the tree
02--Assuming the script is in the trunk of the tree
03 
04Tree = script.Parent.Parent
05 
06script.Parent.ClickDetector.MouseClick:connect(function(player)
07local AxSpeed = player.Character.AxSpeed.Value
08player.Character.Torso.Anchored = true
09 wait(AxSpeed)
10Tree.Trunk.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
11Tree.Foliage1.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
12Tree.Foliage2.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
13Tree.Foliage3.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
14Tree.Foliage4.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,100)
15wait(1)
View all 23 lines...
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 — 10y
0
No problem. aquathorn321 858 — 10y
Ad
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 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 — 10y
0
Thank you for your time, but its still not working ;( Dr_Doge 100 — 10y

Answer this question