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

how to make a part that uses a touch event but effects everyone but you? (see description)

So im trying to make a Flash game, he has this thing where he can go so fast that everyone around him is standing still. I want to do this and use like a Bubble and if they go inside that bubble then they move very slow. Idk if there is a way to make it so the person that made that bubble doesn't get effected by it (I use a touch event)

**this is my code for the part below **

local part = script.Parent



part.Touched:Connect(function(hit)
	local player = hit.Parent:WaitForChild("Humanoid")
	player.WalkSpeed = 1
end)


part.TouchEnded:Connect(function(hit)
	local player = hit.Parent:WaitForChild("Humanoid")
	player.WalkSpeed = 16
end)

1 answer

from what I understand, when a player is touching a certain button, everyone else is moving slowly? Set a variable to check the person who made the bubble, then:

local part = script.Parent
local bubblemaker = nil -- set this variable when someone makes bubble, or use a different value stored somewhere else


part.Touched:Connect(function(hit)
    local player = hit.Parent:FindFirstChild("Humanoid")
if player ~= nil and hit.Parent.Name ~= bubblemaker.Name then
    player.WalkSpeed = 1
end
end)


part.TouchEnded:Connect(function(hit)
    local player = hit.Parent:FindFirstChild("Humanoid")
if player ~= nil and hit.Parent.Name ~= bubblemaker.Name then
    player.WalkSpeed = 16
end
end)

(this is untested, and you will have to edit it to make it work with your game

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