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

How do you make it that you can touch multiple parts, but the script still works as one?

Asked by 8 years ago

The question might not make sense, but i was wondering, how can a Touched event work with multiple parts, (EX: The player touches one of two parts, but it doesn't double the effect)

I could try with one script, or a few in each part. Either way, it's confusing.

Also, the 'Things' Variable is there to show of what I want the player to touch, but only works once.

Sorry if my question doesn't make any sense. I'm not american.

local things = {script.Parent.Chest.muzzle, script.Parent.Chest.muzzle2,script.Parent.Chest.head}

script.Parent.Chest.muzzle.Touched:connect(function(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    if not human then return end
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if not player then return end

    local EnemyLevel = script.Parent.Level.Value/3
    local EXPgainReduced = player.EXPtoGain.Value/2
    local EXP = EnemyLevel+EXPgainReduced/5
    local GUItoAdd = EXP/player.PlayerGui.ScreenGui.Level.Meter.Size.X.Scale

    while true do
        wait()
        if script.Parent.Enemy.Health < 5 then
        player.PlayerGui.ScreenGui.Level.Meter.Event:Fire(EXP)
        wait(31)
        script.Disabled = true
    end
end
end)

1 answer

Log in to vote
0
Answered by
Vezious 310 Moderation Voter
8 years ago

One way is making a value in the player that will change when he is touching an object. Its like debounce but there is one for each player. so you'd do

if Character.Touching.Value == false then
0
Thank you! CrammelApple 50 — 8y
Ad

Answer this question