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

LocalScript does not work?

Asked by 8 years ago

There are no errors, it also does not print "work" so I think its when you touch it

config = script.Parent.Configuration
damage = config.Damage
damageinterval = config.DamageInterval
imageparticle = config.ImageParticleAddress


dying = false
debounce = false

function onTouched(hit) --When Touched
    print("work")
    if debounce == false then
        debounce = true
        local human = hit.Parent:FindFirstChild("Humanoid")
        if human then
            game.ReplicatedStorage.Damage:Clone().Parent = hit.Parent.Torso
            hit.Parent.Torso.Damage.Texture = imageparticle.Value
            dying = true
            damagingfunc(human) --Launches function
        end
    end
end


function offTouched(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    if human then
        if hit.Parent.Torso:FindFirstChild("Damage") then
            hit.Parent.Torso.Damage:Destroy()
        end
        dying = false
        debounce = false
    end
end

function damagingfunc(human)
    local health = game.Players:GetPlayerFromCharacter(human.Parent).stats.health
    while dying == true do
        health.Value = health.Value - damage.Value
        wait(damageinterval.Value)
    end
end

script.Parent.Touched:connect(onTouched)
script.Parent.TouchEnded:connect(offTouched)

1 answer

Log in to vote
1
Answered by 8 years ago

First Check: Is it in one of these places?

A LocalScript will only run Lua code if it is a descendant of one of the following objects: A Player's Backpack, such as a child of a Tool A Player's Character model A Player's PlayerGui A Player's PlayerScripts The ReplicatedFirst service Note: the parent of the LocalScript will determine which client the Lua code will be executed on.

As stated on: http://wiki.roblox.com/index.php?title=API:Class/LocalScript

Second Check: Nothing seems to be wrong with your code, has it worked before?

0
I am not sure how to make a local script of this, it works on a normal script, just not for multiple people LittleBigDeveloper 245 — 8y
0
IS your local script in one of those 5 places? If so, are you referencing things correctly TinyPanda273 110 — 8y
Ad

Answer this question