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

These two scripts work but one is not doing it's job, why?

I'm trying to make a text GUI appear on the screen when a block is touched. the touch script works and it enabled the other script, but it does not work. The script works when it's activated once the game starts, but not when a script activates it.

Touching Block script:

local p = script.Parent
local d = false

p.Touched:Connect(function(otherPart)
	if otherPart and otherPart.Parent then
		local h = otherPart.Parent:FindFirstChild("Humanoid")
		if h then
			if d == true then return end
			d = true
				game.Workspace.LocalScript1.Disabled=false
			wait(1)
			d = false
		end
	end
end)

After Block touched this activates but won't work.

local text = "Congrats!"

local player = script.Parent.Parent
local gui = script.Parent
local sound = Instance.new("Sound",gui)
sound.SoundId = "http://www.roblox.com/asset/?id=14863866"
sound.Pitch = 1
sound.Volume = 0.8
local frame = gui.Frame
local text1 = frame.TextLabel
wait(0.5)
for i = 1,string.len(text),1 do
sound:play()
text1.Text = string.sub(text,1,i)
wait(1)
local text = "Congrats!"
end

1 answer

Line 10 of the first code, you reference a local script which is in the workspace. Local scripts cannot run in the workspace. Here are the places where a local script can run:

  1. A player's Backpack

  2. A player's character model

  3. A player’s PlayerGui

  4. A player’s PlayerScripts.

  5. The ReplicatedFirst service

Hope this helps and have a nice day!

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