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

how do i modify this script to make it clickable?

I cant code at all lol so I'm trying to modify a free model so that instead of me jumping on top of the book, I need to click it. How would i do that? code:

put = script.Parent.Parent.Book
s = script.Parent

bounce = false

function t(p)
if bounce == true then return end
bounce = true
	local h = p.Parent:findFirstChild("Humanoid")
		if h ~= nil then
			local gui = put:GetChildren()
				for i=1, #gui do
					if gui[i].className == "ScreenGui" then
						local x = gui[i]:clone()
						local player = game.Players:GetPlayerFromCharacter(p.Parent)
							if player ~= nil then
								x.Parent = player.PlayerGui
							else
								print("No player found")
							end
					end
				end
		end
wait(1)
bounce = false
end

s.Touched:Connect(t)

please don't make fun of me for trying to modify a free model k thx.

2 comments

0

Insert a click detector and use the MouseClick event

0

/\ added it, didnt work

1 answer

✓ Accepted answer

Add a ClickDetector in a book, and then use this code. In the code, I get the ScreenGuis from the book and clone them into the player clicking. Also make sure it's in a regular script.

local book = script.Parent.Parent.Book
local clickDetector = book:WaitForChild('ClickDetector')

clickDetector.MouseClick:connect(function(plr) --OnClicked
	for i,v in pairs (book:GetChildren()) do--For every child of the book
		if v:IsA('ScreenGui') then--If it's a ScreenGui
			local clonedGUI = v:Clone()--The clone
			clonedGUI.Parent = plr.PlayerGui--Put it in PlayerGui.
		end
	end
end)

1 comment

0

OMG thanks so much. been working a week on this!

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