Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i modify this script to make it clickable?

Asked by 5 years ago

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.

0
Insert a click detector and use the MouseClick event Crazycat4360 115 — 5y
0
/\ added it, didnt work SodaZere 31 — 5y

1 answer

Log in to vote
0
Answered by
popeeyy 493 Moderation Voter
5 years ago

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)
0
OMG thanks so much. been working a week on this! SodaZere 31 — 5y
Ad

Answer this question