@aliaun125 & @Danielhoteaale I have tried creating a script following both contexts, and it appears that while creating one as LocalScript via StarterPlayerScripts
, it seemed that it could not detect the HumanoidRootPart:
→ StarterPlayerScripts
-- Player Property
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
if not (Character) then
return
end
local HumanoidRootPart = Character:FindFirstChildOfClass("HumanoidRootPart")
if (HumanoidRootPart) then
print("True")
elseif not (HumanoidRootPart) then
return
end
-- Billboard Property
local Sign = game.Workspace.Sign
local BillBoard = game.Workspace.Sign.Text.BillboardGui
local Button = BillBoard.Button
-- Services' Property
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
-- Message Property In-Screen
local ScreenGUI = Instance.new("ScreenGui", game.StarterGui)
local Frame = Instance.new("Frame", (ScreenGUI))
local Text = Instance.new("TextLabel", Frame)
local Information = {
ScreenGUI.Enabled == false,
Frame.Visible == true,
Frame.Size == UDim2.new(1,0,1,0),
Frame.BackgroundColor == Color3.new(0,0,0),
Frame.BackgroundTransparency == 0.5,
Text.Size == UDim2.new(1,0,1,0),
Text.BackgroundTransparency == 1,
Text.Text == "This is a sign",
}
UserInputService.InputBegan:Connect(function(input)
BillBoard.Enabled = false
if input.KeyCode == Enum.KeyCode.E then
local Magnitude = (HumanoidRootPart.Parent - Sign.Text.Position).Magnitude
print(Magnitude)
if (Magnitude) <= 25 then
BillBoard.Enabled = true
print(BillBoard.Enabled)
ScreenGUI.Enabled = true
print(Text.Text)
end
end
end)
As the result, I tried creating another one as a normal Script via Workspace
with a few changes… Instead of detecting HumanoidRootPart, it would detect UpperTorso. However, the result was printing issues stating that I am attempting to search for a nil value in the local variable called “Character”:
→ Script
-- Player Property
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
--local Character = Player.Character or Player.CharacterAdded:Wait()
--if not (Character) then
-- return
--end
local UpperTorso = Player.Character:FindFirstChild("UpperTorso")
if (UpperTorso) then
print("True")
elseif not (UpperTorso) then
return
end
-- Billboard Property
local Sign = game.Workspace.Sign
local BillBoard = game.Workspace.Sign.Text.BillboardGui
local Button = BillBoard.Button
-- Services' Property
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
-- Message Property In-Screen
local ScreenGUI = Instance.new("ScreenGui", game.StarterGui)
local Frame = Instance.new("Frame", (ScreenGUI))
local Text = Instance.new("TextLabel", Frame)
local Information = {
ScreenGUI.Enabled == false,
Frame.Visible == true,
Frame.Size == UDim2.new(1,0,1,0),
Frame.BackgroundColor == Color3.new(0,0,0),
Frame.BackgroundTransparency == 0.5,
Text.Size == UDim2.new(1,0,1,0),
Text.BackgroundTransparency == 1,
Text.Text == "This is a sign",
}
UserInputService.InputBegan:Connect(function(input)
BillBoard.Enabled = false
if input.KeyCode == Enum.KeyCode.E then
local Magnitude = (UpperTorso.Parent - Sign.Text.Position).Magnitude
print(Magnitude)
if (Magnitude) <= 25 then
BillBoard.Enabled = true
print(BillBoard.Enabled)
ScreenGUI.Enabled = true
print(Text.Text)
end
end
end)