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

I have a shop but I can't figure out any script?

Okay I am a very very VERY basic scripter and I really need a script. I need guidance. So I have my gui all set up but I want to make it so when you click a dialouge button the npc says like hi wanna see the shop and if you click yes then a shop will open.

1 answer

Hey there! In the public chat, you asked for a script that makes text appear at the head of an NPC, whenever a player touches him. And I got it! Here it is, make sure to put the script in the NPC, and change the "newText" variable to whatever text you want, also u can change the duration of the text, and the TIME DELAY after the player touches the NPC (not that important):

local text = script.Parent.Head.NPC_Text.TextLabel
text.Visible = false
local DELAY = false

local char = script.Parent
local LeftFoot = char.LeftFoot
local LeftHand = char.LeftHand
local LeftLowerArm = char.LeftLowerArm
local LeftLowerLeg = char.LeftLowerLeg
local LeftUpperArm =  char.LeftUpperArm
local LeftUpperLeg = char.LeftUpperLeg
local LowerTorso = char.LowerTorso
local RightFoot = char.RightFoot
local RightHand = char.RightHand
local RightLowerArm = char.RightLowerArm
local RightLowerLeg = char.RightLowerLeg
local RightUpperArm = char.RightUpperArm
local RightUpperLeg = char.RightUpperLeg
local UpperTorso = char.UpperTorso
local Head = char.Head

local newText = "Hello human, I am a robot!"    -- Change to whatever you want

local textDuration = 5.4 -- Change how long the text will be visible

local TIMEDELAY = 0.5 -- Delay between everytime a player touches the NPC


LeftFoot.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(textDuration)
		text.Visible = false
		
		wait(TIMEDELAY)
		DELAY = false
	end
end)

LeftHand.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(textDuration)
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

LeftLowerArm.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(textDuration)
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

LeftLowerLeg.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(textDuration)
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

LeftUpperArm.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(textDuration)
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

LeftUpperLeg.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(textDuration)
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

LowerTorso.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(textDuration)
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

RightFoot.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(wait(textDuration))
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

RightHand.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(wait(textDuration))
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

RightLowerArm.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(wait(textDuration))
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

RightLowerLeg.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(wait(textDuration))
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

RightUpperArm.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(wait(textDuration))
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

RightUpperLeg.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(wait(textDuration))
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

UpperTorso.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(wait(textDuration))
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

Head.Touched:Connect(function()
	if DELAY==false then
		DELAY = true
		
		text.Visible = true
		text.Text = newText
		wait(wait(textDuration))
		text.Visible = false

		wait(TIMEDELAY)
		DELAY = false
	end
end)

Important: Make sure any player that touches the NPC is R15, not R16

2 comments

0

I didn't work :/

0

oh my god

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