-
What do you want to achieve?
I’m making a script for a wire mechanic where a wire gets spawned into the game & welded to a detector part, and I need the detector part to search for touching parts so I can see their values from there. -
What is the issue?
It wasn’t working, so I went back a few steps, made a script that just spawns a part on your cursor but the test part once spawned does not get detected at all…? Any player limbs and parts previously placed in Studio before testing the game however do get detected? -
What solutions have you tried so far?
I’ve tried using a few types of GetPartsinRadius and ones similiar but they all seem to not work, and checking Developer Hub all other posts are along the lines of a weapon colliding with a part & therefore using the Touched event, not being stationary while touching one another, yet even Touched event doesnt seem to work for me.
I am still pretty new to scripting/coding at all, so I have a feeling this may just be a clumsy mistake on my end. Anyone experienced enough to point out my mistake would be greatly appreciated!
My test part spawning script (in a LocalScript inside StarterCharacterScripts)
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
uis.InputBegan:Connect(function(input)
local mouseposx,mouseposy,mouseposz = mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
local mousetarget = mouse.Target
if input.KeyCode == Enum.KeyCode.C then
local block = Instance.new("Part")
block.Size = Vector3.new(5,5,5)
block.Parent = workspace
block.Position = Vector3.new(mouseposx,mouseposy,mouseposz)
block.Name = "GreySpawnedInTestPart"
end
end)
My part detector script (in a Script inside a part in workspace)
while true do
local partsfound = workspace:GetPartsInPart(script.Parent)
for index, value in pairs(partsfound) do
if value then
print(value)
end
end
wait(1)
end
As shown, the part I placed in Studio before I ran the game is detected as usual by the blue part, but the grey part I spawned in with the script ingame is being ignored???