as you can see, when i go in the box and place it, a few seconds later it reactivates again for no reason
FILE:
re.rbxl (62.3 KB)
![Screenshot 2023-12-13 at 8.04.53 PM|690x59]
(upload://2ikZ3rdF15RmjV2bqvm1wgqL2Ai.jpeg)
FILE:
re.rbxl (62.3 KB)
![Screenshot 2023-12-13 at 8.04.53 PM|690x59]
(upload://2ikZ3rdF15RmjV2bqvm1wgqL2Ai.jpeg)
can you show me the script, you have to show the script if you need help
i gave the whole file, you can find it above the print
just give the script, not everyone have time to turn on RobloxStudio
okay
inside the carried part:
local model = script.Parent.Parent
local prompt = script.Parent
local animation = script.Animation
local distanceZ = -2--Model distance from character/ how far the model will be from the character
local distanceY = -0.5--Model distance from the ground
local animationTrack = nil
local owner = nil
prompt.MouseClick:Connect(function(player)
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
if not animationTrack then
animationTrack = humanoid:LoadAnimation(animation)
end
if not model:FindFirstChildWhichIsA("WeldConstraint") and owner == nil and humanoid.Health ~= 0 then
local weld = Instance.new("WeldConstraint", model)
model.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, distanceY, distanceZ)
weld.Part0 = model
weld.Part1 = character.HumanoidRootPart
owner = player.Name
game.ReplicatedStorage.Events.Placing:FireClient(player,"yep",script.Parent.Parent)
animationTrack:Play()
prompt.MaxActivationDistance = 0
wait(0.1)
end
--<<Death Detector>>--
humanoid.Died:Connect(function()
pcall(function()
animationTrack:Stop()
model:FindFirstChildWhichIsA("WeldConstraint"):Destroy()
model.CanCollide = true
owner = nil
prompt.MaxActivationDistance = 10
animationTrack = nil
model.CFrame = model.CFrame * CFrame.new(0,0.2,0)
end)
end)
end)
game.ReplicatedStorage.Events.Placing.OnServerEvent:Connect(function(plr,Pos,out)
if plr.Name == owner then
animationTrack:Stop()
model:FindFirstChildWhichIsA("WeldConstraint"):Destroy()
model.CanCollide = true
owner = nil
animationTrack = nil
model.Velocity = Vector3.new(0,0,0)
model.CFrame = Pos * CFrame.new(0,0.2,0)
end
prompt.MaxActivationDistance = 10
end)
local script(for handling)
grabbed = false
db = false
local runservice = game:GetService("RunService")
local circle
local mouse = game.Players.LocalPlayer:GetMouse()
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local boxe
model = false
rebounce = false
--mouse.TargetFilter = workspace.Table1:WaitForChild("Hitbox")
RHeld = false
THeld = false
out = false
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.R then
RHeld = true
elseif key.KeyCode == Enum.KeyCode.E and grabbed == true then
grabbed = false
if not model then
game.ReplicatedStorage.Events.Placing:FireServer(boxe.CFrame)
elseif model then
game.ReplicatedStorage.Events.Placing:FireServer("Drop")
end
circle.Highlight:Destroy()
circle:Destroy()
elseif key.KeyCode == Enum.KeyCode.T then
THeld = true
end
end)
UIS.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.R then
RHeld = false
elseif key.KeyCode == Enum.KeyCode.T then
THeld = false
end
end)
game.ReplicatedStorage.Events.Placing.OnClientEvent:Connect(function(yep,box,flat)
if yep == "yep" then
grabbed = true
boxe = box
circle = boxe:Clone()
circle.Parent = workspace
circle.Name = "Circle"
circle.CanCollide = false
circle.WeldConstraint:Destroy()
circle.Anchored = true
circle.ClickDetector:Destroy()
local highlight = Instance.new("Highlight",circle)
circle.CFrame = CFrame.new(Vector3.new(0, 0, 0), Vector3.new(0, 0, 0))
highlight.FillColor = Color3.fromRGB(0, 237, 1)
highlight.OutlineColor = Color3.fromRGB(8, 255, 0)
model = false
mouse.TargetFilter = circle
if circle ~= nil then
circle:Destroy()
end
end
end)
mouse.Button1Down:Connect(function()
if grabbed == true then
grabbed = false
if not out and not model then
game.ReplicatedStorage.Events.Placing:FireServer(circle.CFrame)
elseif model and not out then
game.ReplicatedStorage.Events.Placing:FireServer(circle.Primary.CFrame)
elseif model and out then
game.ReplicatedStorage.Events.Placing:FireServer("Drop")
elseif out and not model then
game.ReplicatedStorage.Events.Placing:FireServer(boxe.CFrame)
end
circle:Destroy()
end
end)
local target,pos,norm = nil
local bruh = nil
function UpdatePosition()
local ignoreList = {game.Players.LocalPlayer.Character}
if circle ~= nil then
table.insert(ignoreList,circle)
end
local mouseRay = mouse.UnitRay
local newRay = Ray.new(mouseRay.Origin, mouseRay.Direction.Unit * 10000)
target, pos, norm = workspace:FindPartOnRayWithIgnoreList(newRay, ignoreList)
bruh = Vector3.new(norm.X,0,norm.Z)
end
local function Snap(posy)
PosX = math.floor(mouse.Hit.X / 1 + 0.5) * 1 -- Snaps
PosZ = math.floor(mouse.Hit.Z / 1 + 0.5) * 1 -- Snaps
end
local function isColliding()
local isColliding = false
local touch = circle.PrimaryPart.Touched:Connect(function() end) or circle.Primary.Touched:Connect(function() end)
local touching = circle.PrimaryPart:GetTouchingParts()
for i = 1, #touching do
if (not touching[i]:IsDescendantOf(circle)) and touching[i].Name ~= "White" then
isColliding = true
break
end
end
touch:Disconnect()
return isColliding
end
runservice.Heartbeat:Connect(function()
if grabbed == true and model == true then
UpdatePosition()
Snap()
local modelSize = circle:IsA("Model") and circle:GetExtentsSize() or circle.Size
circle:MoveTo(Vector3.new(PosX, -2.75, PosZ) + bruh * (modelSize.X*0.5))
local col = isColliding()
if not col then
out = false
circle.Highlight.FillColor = Color3.fromRGB(0, 237, 1)
circle.Highlight.OutlineColor = Color3.fromRGB(8, 255, 0)
elseif col then
out = true
circle.Highlight.FillColor = Color3.fromRGB(255, 18, 32)
circle.Highlight.OutlineColor = Color3.fromRGB(255, 70, 47)
end
if RHeld == true and not rebounce then
rebounce = true
circle:PivotTo(circle:GetPivot() * CFrame.Angles(0, math.rad(90), 0))
wait(0.5)
rebounce = false
end
end
if grabbed == true and model == false then
if (mouse.Hit.Position - plr.Character.HumanoidRootPart.Position).Magnitude < 20 and mouse.Target ~= boxe then
out = false
elseif (mouse.Hit.Position - plr.Character.HumanoidRootPart.Position).Magnitude > 20 or mouse.Target == boxe then
out = true
end
UpdatePosition()
local rotation = circle.CFrame - circle.CFrame.Position
local endPos = pos + (norm * (circle.Size * 0.5))
circle.Position = endPos
if RHeld == true then
circle.CFrame = circle.CFrame * CFrame.Angles(0,0.05,0)
elseif THeld == true and db == false then
circle.CFrame = circle.CFrame * CFrame.Angles(math.rad(90), 0, 0)
wait(1)
db = false
end
elseif grabbed == false and circle ~= nil then
circle:Destroy()
end
end)
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
grabbed = false
circle.Highlight:Destroy()
circle:Destroy()
end)
the part decting:
script.Parent.Touched:Connect(function(touch)
if touch.Name == "Box" then
print("ye")
end
end)
script.Parent.TouchEnded:Connect(function(touche)
if touche.Name == "Box" then
print("false")
end
end)
so you want it to print ye when the part touch the box and print false when the collide stop?
no, it already does, my problem is when i put it in the box, the touchended triggers for no reason around four seconds later
I see, I think that’s how it’s work, the state of a part is, when the part is touch it will fire touch event and when the touch is out itwill fire touch ended, but when you stay on the part it will wait a bit and fire the touchended too, but what it will do when the touchended is connect?
I’m not quite sure I understand, as you can see in the video, the console prints false 4 seconds later even though i didn’t touch it nor do anything at all
yeah, it’s how it work, but what you want to do when it fire the touchended event?
nothing, the problem is the touchended shouldn’t fire at all, what i want it to do doesn’t matter
my problem is that the touchended fires when it’s not supposed to
yeah I know, but if I know what you want to do I can help you make a trigger system to fix the issue
???
what i want to do right now is to fix the .touchended so it doesn’t trigger for no reason
what i want is to place the part without it going off randomly after 4 seconds
You should use ZonePlus by ForeverHD, it uses GetPartsBoundInBox instead of Touched Events
Maybe try debounce? Also I think because the box bounces of or something or moves.
Edit : try putting touchended inside of touched function
yeah i tried that, but it seems like it was made with detcting players in mind instead of objects, other alternatives use magnitude or something like it, which requires tracking objects, and my game will have a LOT of objects
wdym?
Im pretty sure it isn’t decting the baseplate, since it is anchored. The player don’t have any onfluicence in this since none of its bodyparts and called “box”
also I don’t think debounce has any affect on this
Yes I am sorry I edited the message see it again
This is what I mean :
script.Parent.Touched:Connect(function(touch)
if touch.Name == "Box" then
print("ye")
script.Parent.TouchEnded:Connect(function(touche)
if touche.Name == "Box" then
print("false")
end
end)
end
end)
huh, thats a werid way of doing it, what does it change if i do it like this?