Basically trying to change some stuff about a part when it’s touched, which does work well the first time, but if a player goes to touched the part again, none of the script executes. I do have debounce’s in place (when part is touched, makes it so it can’t touch again, but if they player presses Q you can touch the part again), but they don’t seem to be working. I have the debounce as a boolean, and the boolean as a BoolValue. Pressing Q does set the debounce to false so the player can touch it again, but when the player touches the part, nothing happens.
Script 1:
local partThing = game.Workspace.pickupPart --Gets the part
--Debounce's
local debounce = Instance.new("BoolValue", partThing)
debounce.Name = "debounce"
debounce.Value = false
partThing.Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and debounce.Value == false then
--The code is here but for readability's sake I've removed unnecessary code
--Checkpoint 1
print("Touched " .. partThing.Name) --Letting me know the code worked
game.Workspace.pickupPart.debounce.Value = true
end
end)
Script 2:
UIS.InputBegan:Connect(function(input, gameProccesedEvent)
if input.KeyCode == Enum.KeyCode.Q then
game.Workspace.pickupPart.debounce.Value = false
print("Dropped")
--Yet again more stuff in here
if game.Workspace.pickupPart.debounce.Value == false then
print("debounce false")
end
end
end)
--in a server script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, goal)
game.Workspace.pickupPart.debounce.Value = goal
end)
and on your UserInputService script remove game.Workspace.pickupPart.debounce.Value = false line and add this one instead: game.ReplicatedStorage.RemoteEvent:FireServer(false)
One other small issue if you don’t mind, is that when you touch the part again, the size of the part isn’t changing inside the script, could you possibly help with this?
local partThing = game.Workspace.pickupPart --Gets the part
--Debounce's
local debounce = Instance.new("BoolValue", partThing)
debounce.Name = "debounce"
debounce.Value = false
partThing.Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and debounce.Value == false then
--Variables
local gloveR = hit.Parent.GloveHandRight --Gets right hand
local HRP = hit.Parent.GloveHandRight.HandRootPart --Root part of hand
--Checkpoint 1
print("Touched " .. partThing.Name) --Letting me know the code worked
--Setting Basics
partThing.CanCollide = false --Disabling CanCollied (let's you walk thorugh it)
partThing.Anchored = false
--Creating weld
local newWeld = Instance.new("WeldConstraint", partThing) --Creates new weld
newWeld.Name = "pickupWeld"
newWeld.Part0 = partThing --Sets cloned part as main part
newWeld.Part1 = HRP --Welds part to HRP
--Resizng & Position
local MiddlePosition = (hit.Parent.GloveHandRight.Finger2.UpperFinger.Position + hit.Parent.GloveHandLeft.Finger2.UpperFinger.Position) / 2
partThing.Position = MiddlePosition --Sets Position
partThing.Size = Vector3.new(1.186, 0.949, 1.191)
partThing.Orientation = HRP.Orientation
--Changes transparency modifier to 0
game.Workspace.pickupPart.LocalTransparencyModifier = 0
--Resize and reposition hitbox
game.Workspace.pickupPart.Part.Size = game.Workspace.pickupPart.Size
game.Workspace.pickupPart.Part.Orientation = game.Workspace.pickupPart.Orientation
game.Workspace.pickupPart.Part.Position = game.Workspace.pickupPart.Position
game.Workspace.pickupPart.debounce.Value = true
end
end)
Are you changing the size again inside UserInputService code? if so you need to use remote events again i mean you can just add that to the current remoteevent code.