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

Cloning problem ?

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

7 comments

0

You're gonna have to explain a bit more. What's your code supposed to do, and what is it actually doing?

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.

0

Also how can i make the camera locked so the player can't scroll out or rotate it ? with right click holding

0

Please fix this script i really want to know and i need this is an important script for me !

0

Is this a local script?

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

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

1 answer

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.

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