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

Cloning problem ?

Asked by
Bulvyte 388 Moderation Voter
8 years ago

I want to make the GUI clonable only 1 time when touched not more. how can i do that ?

Camera = script.Parent.Parent.Parent.Camera1.Camera

local ting = 0

function onTouched(hit)
    if ting == 0 then
    ting = 1
    local check = hit.Parent:FindFirstChild("Humanoid")
    local character = game.Players.LocalPlayer.Character

    if check ~= nil then
        check.WalkSpeed = 0
        character:WaitForChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
        player = game.Players:findFirstChild(check.Parent.Name)
        game.Workspace.Camera.CameraSubject = Camera
        game.Workspace.Camera.CameraType = 1
        exitgui = script.Parent.exitgui:clone()
        exitgui.Parent = player.PlayerGui
    end

    ting = 0
    end
end

script.Parent.Touched:connect(onTouched)

GUI Script

character = game.Players.LocalPlayer.Character

function Click(click)
    local player = game.Players.LocalPlayer
    if player == nil then return end
    game.Workspace.Camera.CameraSubject = player.Character.Humanoid
    game.Workspace.Camera.CameraType = 3
    player.PlayerGui:findFirstChild("exitgui"):remove()
    character:WaitForChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
    character.Humanoid.WalkSpeed = 16

end

script.Parent.MouseButton1Click:connect(Click)

need help with walkspeed in GUI script please

0
You're gonna have to explain a bit more. What's your code supposed to do, and what is it *actually* doing? adark 5487 — 8y
0
What it does when player touches this. It clones a gui into him and makes the camera set on an brick. Then when he wants to exit it he clicks the GUI. Mine problem is that i get 3 guis or 2 guis cloned which i want it to be cloned ONCE so it's like if he touches it 3 times clones it only once and checks if theres more guis it deletes it thats what i want it to do. Bulvyte 388 — 8y
0
Also how can i make the camera locked so the player can't scroll out or rotate it ? with right click holding Bulvyte 388 — 8y
0
Please fix this script i really want to know and i need this is an important script for me ! Bulvyte 388 — 8y
View all comments (3 more)
0
Is this a local script? NeonicPlasma 181 — 8y
0
You could just insert a value into the player, so when they hit the part the Value goes up therefore meaning you can't take the script anymore User#9949 0 — 8y
0
i don't know how to do that.... i've fixed this problem now the problem is that it works only in solo but not in server or online Bulvyte 388 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Use local [var_name] = coroutine.wrap(function([name]) If you do this, the cloning will only work once. After that, it'll deny any more requests because the coroutine will already be dead by the time the gui clones. You can then load the coroutine by doing the following: Assume you do local x = coroutine.wrap(function() and put some stuff inside it. Once you do "x()" (or if you're going to connect it to something, it's "x") like you would with a normal function, the coroutine will load.

Ad

Answer this question