-
What do you want to achieve? Keep it simple and clear!
I want my box to work well and be able to be dropped more better. -
What is the issue? Include screenshots / videos if possible!
The issue is that when my box is dropped inside a player’s character or if touching a player’s character when dropped, they will have it immediately equipped. This seems to happen because of a TouchTransmitter appears inside of the handle when it is unequipped or dropped, even if the TouchTransmitter is destroyed, it stays for one nanosecond before I destroy it so it still makes the box be equipped even though it should only be picked up when using the ProximityPrompt
Box:
-
What solutions have you tried so far?
I changed it from a tool to an accessory but it does the same thing -
Box Script
local self = script.Parent
-- Services --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PhysicsService = game:GetService("PhysicsService")
-- Parts --
local Handle = self:WaitForChild("Handle")
local Corner = self:WaitForChild("Corner")
local Color = self:WaitForChild("Color")
-- Constraints --
local AO = Corner:WaitForChild("AlignOrientation")
local AP = Corner:WaitForChild("AlignPosition")
local WC = Corner:WaitForChild("WeldConstraint")
-- Folders --
local Events = ReplicatedStorage:WaitForChild("Events")
local Values = ReplicatedStorage:WaitForChild("Values")
-- Events --
local GameLoaded = Events:WaitForChild("GameLoaded")
-- Values --
local LoadedValue = Values:WaitForChild("LoadedValue")
-- Logic --
local Humanoid = self:WaitForChild("Humanoid")
local Proxy = Handle:WaitForChild("Proxy")
local Equipped = false
local Delay = false
-- Waiting For Game To Load --
if LoadedValue.Value == false then
GameLoaded.Event:Wait()
end
-- Physics --
PhysicsService:SetPartCollisionGroup(Handle,"Boxes")
PhysicsService:SetPartCollisionGroup(Corner,"Boxes")
-- Design --
Color.SurfaceColor3 = Color3.fromRGB(math.random(1,255),math.random(1,255),255)
-- Event Functions --
self.Equipped:Connect(function()
print("Equipped")
Color.SurfaceTransparency = .5
Corner.Transparency = .5
Humanoid.Value = self.Parent:FindFirstChildOfClass("Humanoid")
local Connection
Connection = Humanoid.Value.Died:Connect(function()
if self.Parent == Humanoid.Value.Parent then
self.Parent = workspace:WaitForChild("ClonedObjects")
self:WaitForChild("Humanoid").Value = nil
Corner.Transparency = 0
self:WaitForChild("Color").SurfaceTransparency = 0
Connection:Disconnect()
end
end)
end)
self.Activated:Connect(function()
wait(.05) -- Delay
local Pos = Handle.CFrame
self.Parent = workspace:WaitForChild("ClonedObjects")
Handle.CFrame = Pos
wait(.001)
Corner.CFrame = Pos
Color.SurfaceTransparency = 0
Corner.Transparency = 0
Delay = true
Equipped = false
wait(.5)
Delay = false
Proxy.Enabled = true
if Humanoid.Value:FindFirstChild("RightHand") then
if Humanoid.Value:WaitForChild("RightHand"):FindFirstChild("RightGrip") then
Humanoid.Value.Parent:FindFirstChild("RightHand"):FindFirstChild("RightGrip"):Destroy()
Humanoid.Value = nil
self.Parent = workspace:WaitForChild("ClonedObjects")
else
Humanoid.Value = nil
self.Parent = workspace:WaitForChild("ClonedObjects")
end
end
end)
Proxy.Triggered:Connect(function(Player)
if not Player.Character:FindFirstChild("Box") and Delay == false then
self.Parent = Player.Character
Humanoid.Value = Player.Character:WaitForChild("Humanoid")
Proxy.Enabled = false
Equipped = true
elseif Player.Character:FindFirstChild("Box") and Delay == false then
Player:WaitForChild("PlayerGui").Box.Enabled = true
wait(2.5)
Player:WaitForChild("PlayerGui").Box.Enabled = false
end
end)
-- Security --
Handle.ChildAdded:Connect(function(Child)
if Child:IsA("TouchTransmitter") then
wait()
Child:Destroy()
end
end)
spawn(function()
while wait(.1) do
if Corner.Position ~= Handle.Position then
print("Fixed Box")
Corner.Position = Handle.Position
end
end
end)
spawn(function()
if Handle:FindFirstChildOfClass("TouchTransmitter") then
Handle:WaitForChild("TouchInterest"):Destroy()
end
end)
if Corner:WaitForChild("WeldConstraint").Enabled == false then
Corner:WaitForChild("WeldConstraint").Enabled = true
end