Hello, how would I check if a player is standing on a part in workspace from a local script? I want to check if a player IS standing on Corner1 then UI will appear for only him.
I should check for the part en do workspace:GetTouchingParts(Part) en check with a for loop to check if a part is descent of players character
1 Like
Could you write a script for me that does that?
You can check if the Part
was Touched by using Part.Touched
, and then check if the Touching Part’s Parent is a Character of a Player using game.Players:GetPlayerFromCharacter
Not very Efficient
Against the Rules.
Well:
function CheckOnPart()
for i,v in pairs(workspace:GetPartsInPart(workspace.Part)) do
if v:IsDescendantOf(game.Players.LocalPlayer.Character) then
return true
end
end
return false
end
if CheckOnPart() then
end
function CheckOnPart2()
for i,v in pairs(game.Workspace.Part:GetTouchingParts()) do -- Only detects parts that are cancollide
if v:IsDescendantOf(game.Players.LocalPlayer.Character) then
return true
end
end
return false
end```
All this seems very unnessacary to check if a Player is touching a Part, all you need is a .Touched
Event
local Player = game.Players.LocalPlayer
BasePart.Touched:Connect(function(hit)
-- checking if the Player is there
if hit:IsDescendantOf(Player.Character) then -- will check if the Object is Parnted under a Object
print("Player Touched a Part")
end
-- if you plan to modify the Player
local Player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Gets Player from Potential Model
if Player then -- if there is a Player
print(Player.." Touched a Part")
end
end)
Also:
That will not work
now it will, but yeah touched is also good, but idk when and where he wants’ to check it.
1 Like