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

How else can i define what the "blade" is if findfirstchild doesn't wanna do it?

Asked by
Echtic 128
5 years ago
Edited 5 years ago

So this is the script:

01  local ev = script.Parent
02 
03local debounce = false
04 
05local Track = nil
06 
07   
08 
09ev.OnServerEvent:Connect(function(player)
10 
11local blade = player.Character:FindFirstChild("Blade")
12 
13player.PlayerStats.SwordExp.Value = player.PlayerStats.SwordExp.Value + 10
14 
15local scc = script.Script:Clone()
16 
17   
18 
19local Anim1 = script.anim1
20 
21local Anim2 = script.anim2
22 
23local char = player.Character or player.CharacterAdded:Wait()
24 
25if debounce == false then
26 
27debounce = true
28 
29Track = char.Humanoid:LoadAnimation(Anim1)
30 
31Track:Play()
32 
33   
34 
35scc.Parent = blade
36 
37   
38 
39game.Debris:AddItem(scc,.5)
40 
41else
42 
43debounce = false
44 
45Track = char.Humanoid:LoadAnimation(Anim2)
46 
47Track:Play()
48 
49   
50 
51scc.Parent = blade
52 
53   
54 
55end
56 
57   
58 
59if player.PlayerStats.SwordExp.Value / player.PlayerStats.MaxSwordExp.Value >= 1 then
60 
61player.PlayerStats.SwordLvl.Value = player.PlayerStats.SwordLvl.Value + 1
62 
63player.PlayerStats.MaxSwordExp.Value = player.PlayerStats.MaxSwordExp.Value + 10
64 
65player.PlayerStats.SwordExp.Value = 0
66 
67end
68 
69   
70 
71if player.PlayerStats.SwordLvl.Value <= 1 then
72 
73player.PlayerStats.MaxSwordExp.Value = 1000
74 
75end
76 
77end)

I need to put that scc script into the blade when needed which should work but doesn’t cause i cannot manage to define the blade properly.
Any ideas how to fix this?

3 answers

Log in to vote
1
Answered by
Fifkee 2017 Community Moderator Moderation Voter
5 years ago
  1. WaitForChild is your best friend
  2. Check if “Blade” is named properly. The *ForChild methods are case-sensitive.
  3. Make sure that “Blade” isn’t being generated client-side. The server wont acknowledge that the blade is being created if it is.

Overall, if WaitForChild doesn’t find it ever, then that means that it’s never being created or moved. WaitForChild can and will find something, no matter how long it takes. Make sure that “Blade” is actually being created. You may have forgotten to clone it, or something. If it’s an equippable object, the model won’t be moved into the player until it is equipped.

Ad
Log in to vote
1
Answered by
SpiralRBX 224 Moderation Voter
5 years ago

In stead of FindFirstChild use WaitForChild. Heres an Example:

1local blade = player.Character:WaitForChild("Blade")

Your friend, Spiral

0
I forgot to mention that waitforchild also doesn't work Echtic 128 — 5y
0
oh ok. rip SpiralRBX 224 — 5y
Log in to vote
0
Answered by 5 years ago

try this

if the blade is the parent of this script you can identify it by simply doing

1local blade = script.Parent

or if it’s something else, why not try:

1local blade = player.Character.Blade

Answer this question