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

What part of this sword script doesn't work with FE?

Asked by
Viking359 161
6 years ago

I'm converting my game to FE and I have a large amount of broken swords. This is the script that is the least broken. The animations still work but the damage doesn't. Should I just use a remote event with a similar script is or there a way to make this script compatible w/o using remote events? Server Script

r = game:service("RunService")

local damage = 50

local slash_damage = 50
local lunge_damage = 50

sword = script.Parent.Handle
Tool = script.Parent

local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
SlashSound.Parent = sword
SlashSound.Volume = .7

local LungeSound = Instance.new("Sound")
LungeSound.SoundId = "rbxasset://sounds\\swordlunge.wav"
LungeSound.Parent = sword
LungeSound.Volume = .6

local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 1

function blow(hit)
    local humanoid = hit.Parent:findFirstChild("Humanoid")
    local vCharacter = Tool.Parent
    local vPlayer = game.Players:playerFromCharacter(vCharacter)
    local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
    if humanoid~=nil and humanoid ~= hum and hum ~= nil then

        tagHumanoid(humanoid, vPlayer)
        humanoid:TakeDamage(damage)
        wait(1)
        untagHumanoid(humanoid)
    end
end

function tagHumanoid(humanoid, player)
    local creator_tag = Instance.new("ObjectValue")
    creator_tag.Value = player
    creator_tag.Name = "creator"
    creator_tag.Parent = humanoid
end

function untagHumanoid(humanoid)
    if humanoid ~= nil then
        local tag = humanoid:findFirstChild("creator")
        if tag ~= nil then
            tag.Parent = nil
        end
    end
end

function attack()
    damage = slash_damage
    SlashSound:play()
    local anim = Instance.new("StringValue")
    anim.Name = "toolanim"
    anim.Value = "Slash"
    anim.Parent = Tool
end

function lunge()
    damage = lunge_damage

    LungeSound:play()

    local anim = Instance.new("StringValue")
    anim.Name = "toolanim"
    anim.Value = "Lunge"
    anim.Parent = Tool


    force = Instance.new("BodyVelocity")
    force.velocity = Vector3.new(0,10,0) --Tool.Parent.Torso.CFrame.lookVector * 80
    force.Parent = Tool.Parent.Torso
    wait(.25)
    swordOut()
    wait(.25)
    force.Parent = nil
    wait(.5)
    swordUp()

    damage = slash_damage
end

function swordUp()
    Tool.GripForward = Vector3.new(-1,0,0)
    Tool.GripRight = Vector3.new(0,1,0)
    Tool.GripUp = Vector3.new(0,0,1)
end

function swordOut()
    Tool.GripForward = Vector3.new(0,0,1)
    Tool.GripRight = Vector3.new(0,-1,0)
    Tool.GripUp = Vector3.new(-1,0,0)
end

function swordAcross()
    -- parry
end

Tool.Enabled = true
local last_attack = 0
function onActivated()

    if not Tool.Enabled then
        return
    end

    Tool.Enabled = false

    local character = Tool.Parent;
    local humanoid = character.Humanoid
    if humanoid == nil then

        return 
    end

    t = r.Stepped:wait()

    if (t - last_attack < .2) then
        lunge()
    else
        attack()
    end

    last_attack = t

    --wait(.5)

    Tool.Enabled = true
end

function onEquipped()
    UnsheathSound:play()
end


script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)


connection = sword.Touched:Connect(blow)

The script is directly inside the tool.

0
Well you don't need a connection variable saSlol2436 716 — 6y
0
Plus FindFirstChild is the correct way to write the function, not findFirstChild saSlol2436 716 — 6y
0
Plus connect is depricated use Connect please saSlol2436 716 — 6y
0
By the way another way of saying if hum ~= nil then end is if hum then end saSlol2436 716 — 6y
View all comments (5 more)
0
And also its game.Players:GetPlayerFromCharacter() saSlol2436 716 — 6y
0
Plus when using events with a wait its best to do r.Stepped:Wait() since wait() is depricated saSlol2436 716 — 6y
0
calm down Thundermaker300 554 — 6y
0
Wait since when was wait() deprecated? It isn't.. @saSlol2436 Thundermaker300 554 — 6y
0
All of those don't really affect the script and wait() is not deprecated Viking359 161 — 6y

Answer this question