#Lava spin

1 messages · Page 1 of 1 (latest)

crimson karma
#

I want to do a lava spin. When I press the button, it activates and when I press it again, it stops. How can I do this?

dry prairie
#

like a proximity prompt?

#

@crimson karma

crimson karma
#

I don't know anything about it, but I'm trying to make a minigame where I press the button and it activates and stops and the lava spins. I can play it with my friends.

dry prairie
#

So, let's say this?

  1. You click a red button
  2. A lava block spins
  3. You click it again, it stops spinning
crimson karma
#

Yes, it is exactly as I want. If I ask, can I have it modeled for me?

dry prairie
#

create a part in workspace: ButtonPart and LavaPart

#

and add a click detector in ButtonPart

crimson karma
#

okay

#

I did

dry prairie
#

Sorry for the delay, was working on my own project, but anyways place this into server script service. Whether it deals damage or not requires a separate script which i cant make at the moment

local ButtonPart = game.Workspace:WaitForChild("ButtonPart",5)
local LavaPart = game.Workspace:WaitForChild("LavaPart",5)

-- Variables
local spinSpeed = 90 -- How to spin the lava part (in degrees)

local isSpinning = false

-- Don't change the stuff below

if not ButtonPart then
    print("Ensure ButtonPart is created in workspace and is named exactly 'ButtonPart'")
end
if not LavaPart then
    print("Ensure LavaPart is created in workspace and is named exactly 'LavaPart'")
end

local clickDetector = ButtonPart:WaitForChild("ClickDetector",5)

if not clickDetector then
    print("Ensure a ClickDetector is inserted into ButtonPart.")
end

clickDetector.MouseClick:Connect(function(click) -- We detect the click
    isSpinning = not isSpinning
    if isSpinning then
        while isSpinning do
            local delta = task.wait() -- Time since last frame
            local rotateAmount = math.rad(spinSpeed * delta)
            LavaPart.CFrame = LavaPart.CFrame * CFrame.Angles(0, rotateAmount, 0)
        end
    end
end)
crimson karma
#

Where should I paste this and in which section?

random daggerBOT
#

studio** You are now Level 1! **studio

dry prairie
#

a new server script in server script service

#

This code might not be that good because im still intermediate and am working on my own project at the moment, but should fulfill what you asked for

#

You can ask AI tools like ChatGPT to help you create code, but ensure you understand what the code actually does, and don't let it replace your learning

crimson karma
#

i paste

dry prairie
#

whats wrong

crimson karma
#

thanks

#

thank you w

#

worked

dry prairie
#

No problem

crimson karma
#

I apologize for bothering you. It's a responsibility. More information. Players can touch the camera from a distance. How do I set it up?

dry prairie
#

well if you want the range from where the players can click the button be smaller, you can click on the ClickDetector and change the MaxActivationDistance from 32 to something else

#

I'm not really sure what you're asking me for