Hey there. I am curious if you can make maybe a part inside the character, set that part’s CFrame/Position to the position of the object I want the player to touch, and still trigger the touched event?
What I tried:
local p1 = game.Players.LocalPlayer.Character
if p1:FindFirstChild("TouchPart") then p1.Parent.TouchPart:Destroy() end
local p = Instance.new("Part")
p.Name = "TouchPart"
p.CanCollide = false
p.Anchored = false
p.Parent = p1
p1.TouchPart.CFrame = (game.Workspace.WinPads.WinPad5.CFrame * CFrame.new(0, 5, 0));
There are some things that I see that could be changed with this script:
p1 is only checking for the Player’s Character once, there is the sudden chance that it may not work so add another conditional check with LocalPlayer.CharacterAdded:Wait()
What script is this? If this is a ServerScript, it cannot work as there’s no possible way to obtain the LocalPlayer this way (Hence why LocalScripts exist!)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local WinPad = workspace.WinPads:WaitForChild("WinPad5")
if Character:FindFirstChild("TouchPart") then
Character.TouchPart:Destroy()
end
local P = Instance.new("Part")
P.Name = "TouchPart"
P.CanCollide = false
P.Anchored = false --This would just fall to the void...? Did you mean to set this to true?
P.CFrame = WinPad.CFrame * CFrame.new(0, 5, 0)
P.Parent = Character
The only Instance I could really see is that the Part is already falling the moment you parent it to the Character, you could either set the TouchPart's CanCollide property to true, or the Anchored property (Although I am unsure if that’ll make the Character lock in place)
Not sure how you would detect touch without the character touching the part, perhaps you mean Magnitude? This checks proximity between 2 points.
local Magnitude = (part.Position - character.HumanoidRootPart.Position).Magnitude
if Magnitude < 10 then
-- touchy stuff
end
Otherwise, you’d have to do a complicated method of welding a large invisible part to the player’s root part and make the script detect that when they touch.