#help

89 messages · Page 1 of 1 (latest)

boreal hornet
#

I'll just make it for you.

local part = script.Parent

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then-- every character has a humanoid, so this is basically a "person checker"
        local char = hit.Parent
        local humanoid = char:WaitForChild("Humanoid")
        
        humanoid.JumpHeight = 0
        wait(14)
        humanoid.JumpHeight = 7.2
    end
end)
#

So the player stops moving completely?

#

I can stop them from using any controls at all, or I can just make it so they can't jump or walk.

#

you can change the seconds in "wait(14)" if you want

#

I think so

#

let me try it outt

#

Is your game in R6 or R15?

boreal hornet
#
local part = script.Parent

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then-- every character has a humanoid, so this is basically a "person checker"
        local char = hit.Parent
        local humanoid = char:WaitForChild("Humanoid")
        
        local function changeAnchor()
            for _, object in ipairs(char:GetChildren())  do
                if object:IsA("MeshPart") then
                    if object.Anchored == true then
                        char:FindFirstChild("HumanoidRootPart").Anchored = false
                        object.Anchored = false
                        humanoid.JumpHeight = 7.2
                        humanoid.WalkSpeed = 16
                    else
                        humanoid.JumpHeight = 0
                        humanoid.WalkSpeed = 0
                        char:FindFirstChild("HumanoidRootPart").Anchored = true
                        object.Anchored = true
                    end
                end
            end
        end

        changeAnchor()
        wait(14)
        changeAnchor()
    end
end)
#

Are you making it like ice?

#

the script runs every time you step on it

#

if you're actively stepping on it, it will constantly be freezing you

#

I can make a cooldown for it

#

if you want

#

it's like 3 lines of code

#

What does?

#

if you press it, it freezes you?

#
local part = script.Parent
local debounce = false

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then-- every character has a humanoid, so this is basically a "person checker"
        local char = hit.Parent
        local humanoid = char:WaitForChild("Humanoid")
        
        local function changeAnchor()
            for _, object in ipairs(char:GetChildren())  do
                if object:IsA("MeshPart") then
                    if object.Anchored == true then
                        char:FindFirstChild("HumanoidRootPart").Anchored = false
                        object.Anchored = false
                        humanoid.JumpHeight = 7.2
                        humanoid.WalkSpeed = 16
                    else
                        humanoid.JumpHeight = 0
                        humanoid.WalkSpeed = 0
                        char:FindFirstChild("HumanoidRootPart").Anchored = true
                        object.Anchored = true
                    end
                end
            end
        end
        if not debounce then
            debounce = true

            changeAnchor()
            wait(14)
            changeAnchor()
            wait(1) -- Change this to how long you don't want to be frozen after you unfreeze.
            debounce = false
        end
    end
end)

So debounce was added. This means, if you get frozen, you can't get frozen again a second.

#

Alright. Feel free to edit that second wait() at the bottom to how long you don't want to be frozen after you unfreeze.

#

for testing purposes, change the wait(14) to wait(3)

#

let me test it rq

#

screenshot the whole script and send it to me

#

make sure to add "local debounce = false" at the very top, just under "local part = script.Parent"

#

this is mine

#

I just tested it and it's working

#

Part can have any name, as long as the script is inside of the part.

#

Do you have the "output" menu open?

#

it gives errors when things aren't coded right, and will tell you exactly what causes the error

#

All of that is because of a plugin. Try scrolling up and seeing if there's any other error code.

#

The plugin should have no effect on the script.

#

Can you explain to me what you're doing in studio with this script, so I can help you out with it?

#

yeah, and what part the script is in

#

CanCollide doesn't effect touch. There is a specific property in each part called "CanTouch". If that's enabled, the "part.Touched" will work.

#

it freezes for 3 seconds. You can increase the wait(3) to wait(7) or something if you want

#

are you trying to make all of the parts in the model do this or just one?

#

So what exactly is happening? It's not freezing?

#

add

print("1")```to somewhere inside of the changeAnchor function
#

then when it runs it'll print the number 1 to the output

#

and you'll know it's running

#

somewhere in here

#

actually

#

yeah put it right below the "if object:IsA("MeshPart") then" line

#

I've got to go do something, I'll check back in with you later

boreal hornet
#

Sorry I've been busy

#

Help with what?

#

I'm still not sure what you're doing with the script, so until I do, I can't help any further

#

Okay so, press the button, part pops up, after 15 seconds it goes away, and if you touch it, it freezes you for a certain amount of time.

#

Right?

#

Is it in a local or server script?

#

does your studio look like this?

#

same icons and everything?

#

this is the difference

#

okay, that's good

#

now, instead of moving the part from lighting to workspace, put the part in ReplicatedStorage. When you press the button, it will clone the part and put the clone in workspace, then after 15 seconds, delete it.

plain krakenBOT
#

studio** You are now Level 7! **studio

boreal hornet
#

That is likely because you're changing it's parent

#

rather than cloning it

#

and changing the clone's parent

#

I can make the script for you

#

What is "disasters"?

#

how about

#

you send the whole script of the click detector

#

I see. Place Disasters in ServerStorage, and when something happens, clone the model and set the clone's parent to workspace.

#

I can make the script for you if you answer this; what is the trigger that causes the folder to go into lighting?

#

is it the button?

#

okay, I can work with that

#
local clickdetector = script.Parent.ClickDetector

local ServerStorage = game:GetService("ServerStorage")
local disasters = ServerStorage:WaitForChild("Disasters")

clickdetector.MouseClick:Connect(function()
    local newFolder = disasters:Clone()
    newFolder.Parent = workspace
    wait(15)
    newFolder:Destroy()
end)
#

does one come after the other?

#

like one will disappear, then the next, then the next?

#

So what's the 15 seconds you mentioned for?

#

So, one disaster at a time, right?

#

Are you trying to make that, or is it already made?

#

the script for one disaster each press?

#

So what script am I trying to create?

#

which one of the "test" models is the freeze one?

#

So when you click it, Test15 is brought into workspace alone?

plain krakenBOT
#

studio** You are now Level 7! **studio

boreal hornet
#

if Test15 is the one

#

that is randomly selected?

#

if you send me the script that you have made for the random selection, I can remake it to the clone() way

#
local Push1 = game.Workspace:WaitForChild("Button"):WaitForChild("ButtonThing")
local PushSound = script.Parent["ButtonSound"]
local ServerStorage = game:GetService("ServerStorage")
local disasters = workspace:FindFirstChild("Disasters") or ServerStorage:FindFirstChild("Disasters")
disasters.Parent = ServerStorage

--Functions--
function choose(tab)
    local n = math.random(1,#tab)
    local obj = tab[n]
    return obj
end

function OnClick()
    script.Disabled = true
    PushSound:Play()
    Push1.BrickColor = BrickColor.new("Really red")
    wait(0.1)
    local disaster = choose(disasters:GetChildren()):clone()
    disaster.Parent = workspace
    wait(disaster.WaitTime.Value)
    disaster:Destroy()
    Push1.BrickColor = BrickColor.new("Lime green")
    wait(1)
    script.Disabled = false
end


--Main Game--
script.Parent.ClickDetector.MouseClick:connect(OnClick)
```I think I've changed everything related to "lighting" to ServerStorage, correct me if I'm wrong and I'll update this message.
#

yeah

#

well, there's only 3 lines of code for the debounce

#
local part = script.Parent

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then-- every character has a humanoid, so this is basically a "person checker"
        local char = hit.Parent
        local humanoid = char:WaitForChild("Humanoid")
        
        local function changeAnchor()
            for _, object in ipairs(char:GetChildren())  do
                if object:IsA("MeshPart") then
                    if object.Anchored == true then
                        char:FindFirstChild("HumanoidRootPart").Anchored = false
                        object.Anchored = false
                        humanoid.JumpHeight = 7.2
                        humanoid.WalkSpeed = 16
                    else
                        humanoid.JumpHeight = 0
                        humanoid.WalkSpeed = 0
                        char:FindFirstChild("HumanoidRootPart").Anchored = true
                        object.Anchored = true
                    end
                end
            end
        end
        changeAnchor()
        wait(14)
        changeAnchor()
        wait(1)
    end
end)
#

There you go, debounce-free.

#

If it's in server storage, I don't think exploiters can access it now. Also, it's a much better managing system, because if you have a disaster that destroys parts, the map will be the same when re-loaded because it clones the original unchanged one from a safe place.

boreal hornet
#

YEAH