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:

  local ev = script.Parent

local debounce = false

local Track = nil



ev.OnServerEvent:Connect(function(player)

local blade = player.Character:FindFirstChild("Blade")

player.PlayerStats.SwordExp.Value = player.PlayerStats.SwordExp.Value + 10

local scc = script.Script:Clone()



local Anim1 = script.anim1

local Anim2 = script.anim2

local char = player.Character or player.CharacterAdded:Wait()

if debounce == false then

debounce = true

Track = char.Humanoid:LoadAnimation(Anim1)

Track:Play()



scc.Parent = blade



game.Debris:AddItem(scc,.5)

else

debounce = false

Track = char.Humanoid:LoadAnimation(Anim2)

Track:Play()



scc.Parent = blade



end



if player.PlayerStats.SwordExp.Value / player.PlayerStats.MaxSwordExp.Value >= 1 then

player.PlayerStats.SwordLvl.Value = player.PlayerStats.SwordLvl.Value + 1

player.PlayerStats.MaxSwordExp.Value = player.PlayerStats.MaxSwordExp.Value + 10

player.PlayerStats.SwordExp.Value = 0

end



if player.PlayerStats.SwordLvl.Value <= 1 then

player.PlayerStats.MaxSwordExp.Value = 1000

end

end)

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:

local 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

local blade = script.Parent

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

local blade = player.Character.Blade

Answer this question