#2 things
1 messages · Page 1 of 1 (latest)
locate a player?
you mean like how to reference a player or get a player value?
and 2. use .Touched event, sometimes some objects like model dont have .Touched so just beware of that
and then when you use .Touched, you'll get "otherpart" as the parameter value
the other part is what touched the part
so you can check by using if OtherPart.Name == "TargetPart" then
both
i do use the touch event
but lets say i want object A to execute a function if ONLY object C touches it
Use .Touched so like
local objectA = script.Parent
local objectC = workspace.ObjectC
objectA.Touched:Connect(function(hit)
if hit == objectC then
-- your function
end
end)
local sword = game.StarterPack.Tool.Handle
local humanoid = game.Players.LocalPlayer.Character
local block = game.Workspace.block
sword.Touched:Connect(function(hit)
if hit == block then
print("Don't touch that dial!")
end
end)
like this??
Ig but it's a sword maybe u want that it only detects the part that touched it when you swing?
Oh cus
Don't do game.Starterpack its not the tool that the player is holding, it's just a copy of it
oh
So maybe do
local plr = game.Players.LocalPlayer
local tool = plr.Character:WaitForChild("Tool") -- the equipped tool
local sword = tool:WaitForChild("Handle")
local block = workspace:WaitForChild("Block")
sword.Touched:Connect(function(hit)
if hit == block then
print("Don't touch that dial!")
end
end)
** You are now Level 1! **
it works
congrat
you can also do that
but that only works if you have the reference of the object