there is the script: , so in roblox studio i can talk with NPC with clicking button but in-game i saw a error error: --HumanoidRootPart is not a valid member of Model Stack Begin Script 'Players.FuddziezYT.PlayerGui in StarterGui.NPCText.Changeit', Line 14 Stack end
local UIS = game:GetService("UserInputService")
local Template = script.Parent:WaitForChild("Template")
local E = script.Parent.Parent:WaitForChild("EThing"):WaitForChild("E")
local VarHolder
local Text
local CurrentTrigger
local NPC
local db
local abletochange = true
local StoredValues = {}
game.Players.LocalPlayer.Character.HumanoidRootPart.Touched:Connect(function(o)
if(o.Name=="TriggerBlock")then
CurrentTrigger = o.NPCTitle.Value
E.Visible = true
E.Parent.Adornee = o
NPC = o.Parent.NPC
end
end)
game.Players.LocalPlayer.Character.HumanoidRootPart.TouchEnded:Connect(function(o)
if(o.Name=="TriggerBlock")then
CurrentTrigger = nil
E.Visible = false
E.Parent.Adornee = nil
NPC = nil
end
end)
UIS.InputBegan:Connect(function(inputObject, gameProcessedEvent)
if(inputObject.KeyCode==Enum.KeyCode.E)and(not(db))then
if(CurrentTrigger)then
SetNewNpc()
end
end
end)
function SetNewNpc()
if(abletochange)then
VarHolder = NPC.Parent.TriggerBlock
TextValue = VarHolder.Text
Text = TextValue.Value
SetNewTextBox()
end
end
function SetNewTextBox()
if(not(db))then
db = true
DisableMove()
local TextBox = Template:Clone()
TextBox.Parent = script.Parent
TextBox.Text = ""
TextBox.Size = UDim2.new(0,500,0,100)
TextBox.Position = UDim2.new(0.5,-250,1,-150)
TextBox.Visible = true
for i=1,string.len(Text) do
TextBox.Text = string.sub(Text, 1, i)
wait(0.02)
end
UIS.InputBegan:Wait()
TextBox:Destroy()
if(TextValue:FindFirstChildOfClass("StringValue"))then
VarHolder = TextValue
TextValue = VarHolder.Text
Text = TextValue.Value
abletochange = false
db = false
SetNewTextBox()
else
EnableMove()
wait(1)
db = false
abletochange = true
end
end
end
function DisableMove()
if(game.Players.LocalPlayer.Character.Humanoid.WalkSpeed~=0)then
StoredValues = {game.Players.LocalPlayer.Character.Humanoid.WalkSpeed,game.Players.LocalPlayer.Character.Humanoid.JumpPower}
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0
end
end
function EnableMove()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = StoredValues[1]
game.Players.LocalPlayer.Character.Humanoid.JumpPower = StoredValues[2]
end
