Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.