So I want a script to activate once i get near, I have a debug script that is not running when i test it, the script is located in StarterGui in a captions type GUI. When I get near the block, it does not print, here is some code snippets.
--Assign Values
local Part = game.Workspace.PowerBox.Main
local HRP = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local WriteToText = script.Parent:WaitForChild("ToolText"):WaitForChild("ToolText")
if (Part.Position - HRP.Position).Magnitude < 8 then
print("working")
end
However, in a simillar script, this works fine when I activate it.
local HRP = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")
local Part = game.Workspace.PowerBox.Main
UIS.InputBegan:Connect(function(keyCode)
if keyCode.keyCode == Enum.KeyCode.E then
if (Part.Position - HRP.Position).Magnitude < 8 then
print("working2")
end
end
end)
If anyone can help me figure out why it is not executing, please answer. If it is a problem, can I also have a fix to this? Many thanks.
-reidlab
