of     1   

Clirex
#182513528Wednesday, January 27, 2016 8:18 PM GMT

-- So I attempted to make it so that it can't be glitched, and I sort of did but -- If someone touches the part many times and walks away it will just open and close -- forever -- Also it doesn't always function the way I want it to (sometimes when you walk away, -- the door stays open) -- pls help me fix local Opened = false local Moving = false local Host = script.Parent local TouchPart = Host.TouchPart local Players = game:GetService("Players") local OpenedValues = { [0.10] = false, [-0.10] = true } local function MoveDoors(Direction) local InitialOpened = Opened while Moving do wait() end if Opened == InitialOpened and Opened == OpenedValues[Direction] then Moving = true for _, Door in next, {Host.DoorLeft, Host.DoorRight} do local NewDirection = Vector3.new(Door.Name == "DoorLeft" and Direction or -Direction, 0, 0) spawn(function() for i = 1, 5.1, math.abs(Direction) do wait() Door.Base.CFrame = Door.Base.CFrame-NewDirection Door.End.CFrame = Door.End.CFrame-NewDirection end Moving = false end) end end end TouchPart.Touched:connect(function(Hit) if not Opened and Players:GetPlayerFromCharacter(Hit.Parent) then MoveDoors(0.10) Opened = true end end) TouchPart.TouchEnded:connect(function(Hit) if Opened and Players:GetPlayerFromCharacter(Hit.Parent) then for _, Part in next, TouchPart:GetTouchingParts() do if Players:GetPlayerFromCharacter(Part.Parent) then return end end MoveDoors(-0.10) Opened = false end end)
WoolHat
#182513654Wednesday, January 27, 2016 8:21 PM GMT

Add in a debounce. If you don't know what it is, read here: http://wiki.roblox.com/index.php?title=Debounce Even in the first paragraph it describes your problem pretty well. Keeps your code from repeating when you do not wish it to.
Clirex
#182513941Wednesday, January 27, 2016 8:26 PM GMT

it already has debounces I need to add another one but I don't know where or how exactly it's confusing
WoolHat
#182513963Wednesday, January 27, 2016 8:27 PM GMT

Upon reading more closely, I realized that you do have a debounce in there. I just read the first paragraph and skimmed. again. noice. I guess to clarify, this script, are you attempting to make the door stay open when a player is touching, and have it close when they stop touching a block?
Clirex
#182514171Wednesday, January 27, 2016 8:30 PM GMT

yes i am im a good scripter as in i know how everything works and know most of the wiki, but sometimes i make stupid mistakes i dont know how to do this correctly pls help
Clirex
#182514831Wednesday, January 27, 2016 8:41 PM GMT

bump
Clirex
#182515730Wednesday, January 27, 2016 8:57 PM GMT

bump
Clirex
#182516983Wednesday, January 27, 2016 9:16 PM GMT

bump
Vaae
#182517298Wednesday, January 27, 2016 9:21 PM GMT

Touch events are terrible. Use magnitude.
Clirex
#182518798Wednesday, January 27, 2016 9:43 PM GMT

thats dumb im not gonna track every single player
Clirex
#182519325Wednesday, January 27, 2016 9:51 PM GMT

bump
Clirex
#182535086Thursday, January 28, 2016 2:06 AM GMT

bump
Clirex
#182539470Thursday, January 28, 2016 3:13 AM GMT

bump

    of     1