Soooo. This problem is a time dissolver. I'm trying to do a game (rpg) with abilities and skills BUT , there is the thing : There's a level system and i wish the abilities to evolve with the level... There's the script... :(
local repstore = game:WaitForChild("ReplicatedStorage") local Remote = repstore.OFA:WaitForChild("Punch") Remote.OnServerEvent:connect(function(player) LDS = player:FindFirstChild("leaderstats") Level = LDS.Level end) function onTouched(hit) local human = hit.Parent:FindFirstChild("Humanoid") if (human ~= nil ) and debounce == false and human ~= script.Parent.Parent.Humanoid then human:TakeDamage(Level.Value * 3) local position = Instance.new("BodyVelocity",hit.Parent.HumanoidRootPart) position.MaxForce = Vector3.new(999999999999999,9999999999999,999999999999999) position.P = 300 position.Velocity = script.Parent.Parent:FindFirstChild("LowerTorso").CFrame.UpVector * 5 game.Debris:AddItem(position,0.1) script.Disabled = true debounce = true wait(1) debounce = false end end script.Parent.Touched:connect(onTouched)
local repstore = game:WaitForChild("ReplicatedStorage") local Remote = repstore.OFA:WaitForChild("Punch") Remote.OnServerEvent:connect(function(player) LDS = player:FindFirstChild("leaderstats") Level = LDS.Level end)
(This part was used to get local player)
The attack deals damage but when i increase the level, attack damage don't increase. My life is a entire nightmare because of this.
Any help is accepted. Thanks for reading. Arthas.
EDIT : This script goes with an other one :
local repstore = game:WaitForChild("ReplicatedStorage") local Remote = repstore.OFA:WaitForChild("Punch") Remote.OnServerEvent:connect(function(player) LArm = player.Character:WaitForChild("LeftLowerArm") RArm = player.Character:WaitForChild("RightLowerArm") local human = player.Character:FindFirstChild("Humanoid") local canattack = true local Damage2 = script.Damage:Clone() Damage2.Parent = RArm canattack = false human:LoadAnimation(script.L):Play() Damage2.Disabled = false wait(0.6) Damage2:Destroy() canattack = true end)
EDIT2 : I think i do everything wrong because of my unexpericence with lua.
In the onTouched function you never call call the RemoteEvent therefor the script doesn't know what level you are
There is no need to do ["Level"]
, you can simply do Level
. Object names in brackets usually have more than one word in their name, which is why they have brackets. Lua can't detect an object name with more than one word without brackets.
As for a nil debunk-er:
local level = LDS:FindFirstChild("Level") if level then -- Code end
This should fix your problem, as it checks to see if the value actually exists or not. If it doesn't, the script stops.