Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Part Detecting Script Not Working?

Problem: The output does not print anything, therefore something is wrong, it is a local script

local Player = game.Players.LocalPlayer
local Person = Player.Character.Torso.Position
local Water = game.Workspace.Water1.Position
local button = script.Parent


button.MouseButton1Down:connect(function()

if (Person - Water).magnitude <= 40 then 
	 print('He is near waffles') 
 end

end)

1 answer

✓ Accepted answer

You have the idea. Im not sure if this is a LocalScript or not.. But I can edit it if you need! :)

local Player 		=game.Players.LocalPlayer
local Torso			=workspace:WaitForChild(Player.Name).Torso
local Water			=workspace:WaitForChild("Water1")
local Button		=script.Parent -- a TextButton or something

function gPos()
	return({ Torso.Position; Water.Position })
end

Button.MouseButton1Click:connect(function()
	local pos=gPos()
	 local gp1,gp2=pos[1],pos[2]
 	if gp1~=nil and gp2~=nil then
		if ((gp1-gp2).magnitude) <= 40 then
			print(Player.Name.. " is near the waffles")
		end
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.