#Fuse Box X Lamps

1 messages · Page 1 of 1 (latest)

keen dirge
#

Hi! im trying to make so when the player has found all the fuses they can put it inside a fuse box and then a door should open (probably with a remote event idk) Ill send my current script in chat because it doesnt work.

#

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local FuseTracker = require(ReplicatedStorage:WaitForChild("FuseTracker"))
local errorEvent = ReplicatedStorage:WaitForChild("FuseBoxErrorEvent")
local successEvent = ReplicatedStorage:WaitForChild("FuseBoxSuccessEvent")

local fuseBox = script.Parent
local prompt = fuseBox:WaitForChild("ProximityPrompt")

-- Find the door to open (will search for a Model or Part named "Door" in workspace)
local door = workspace:FindFirstChild("Door", true)

print("[FuseBoxInteraction] FuseBox interaction system ready")

if door then
print("[FuseBoxInteraction] Found door to open:", door:GetFullName())
else
warn("[FuseBoxInteraction] No door found in workspace! Create a Model or Part named 'Door' to enable door opening.")
end

prompt.Triggered:Connect(function(player)
print("[FuseBoxInteraction]", player.Name, "interacted with FuseBox")

if FuseTracker.HasAllFuses(player) then
    print("[FuseBoxInteraction]", player.Name, "has all 4 fuses! Opening door...")
    
    -- Disable the prompt so it can't be triggered again
    prompt.Enabled = false
    
    -- Open the door
    if door then
        if door:IsA("Model") then
            -- If door is a Model, move it
fervent wedgeBOT
#

studio** You are now Level 2! **studio

keen dirge
#

upward or to the side
local primaryPart = door.PrimaryPart or door:FindFirstChildWhichIsA("BasePart")
if primaryPart then
local targetCFrame = primaryPart.CFrame * CFrame.new(0, 10, 0) -- Move 10 studs up
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween = TweenService:Create(primaryPart, tweenInfo, {CFrame = targetCFrame})
tween:Play()
print("[FuseBoxInteraction] Door Model opening animation started")
end
elseif door:IsA("BasePart") then
-- If door is a Part, move it or make it transparent
local targetCFrame = door.CFrame * CFrame.new(0, 10, 0)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween = TweenService:Create(door, tweenInfo, {CFrame = targetCFrame, Transparency = 1})
tween:Play()

            -- Disable collision after animation
            task.delay(2, function()
                door.CanCollide = false
            end)
            
            print("[FuseBoxInteraction] Door Part opening animation started")
        end
    end
    
    -- Fire success message to client
    successEvent:FireClient(player)
else
    local collectedCount = FuseTracker.GetCollectedCount(player)
    print("[FuseBoxInteraction]", player.Name, "only has", collectedCount, "fuses. Need all 4!")
    
    errorEvent:FireClient(player)
end

end)

knotty mist
keen dirge
#

local FuseTracker = {}

local playerFuses = {}

function FuseTracker.InitializePlayer(player)
if not playerFuses[player.UserId] then
playerFuses[player.UserId] = {
["Fuse 1"] = false,
["Fuse 2"] = false,
["Fuse 3"] = false,
["Fuse 4"] = false
}
print("[FuseTracker] Initialized fuses for player:", player.Name)
end
end

function FuseTracker.CollectFuse(player, fuseName)
FuseTracker.InitializePlayer(player)

if playerFuses[player.UserId][fuseName] ~= nil then
    playerFuses[player.UserId][fuseName] = true
    print("[FuseTracker] Player", player.Name, "collected", fuseName)
    return true
else
    warn("[FuseTracker] Invalid fuse name:", fuseName)
    return false
end

end

function FuseTracker.HasAllFuses(player)
FuseTracker.InitializePlayer(player)

local fuses = playerFuses[player.UserId]
return fuses["Fuse 1"] and fuses["Fuse 2"] and fuses["Fuse 3"] and fuses["Fuse 4"]

end

function FuseTracker.GetCollectedCount(player)
FuseTracker.InitializePlayer(player)

local count = 0
for fuseName, collected in pairs(playerFuses[player.UserId]) do
    if collected then
        count = count + 1
    end
end
return count

end

function FuseTracker.ClearPlayerFuses(player)
playerFuses[player.UserId] = nil
print("[FuseTracker] Cleared fuses for player:", player.Name)
end

return FuseTracker

knotty mist
keen dirge
#

when i try inputing the fuses?

knotty mist
keen dirge
#

this is what shows up when starting the game

#

nothing changes when trying to input the fuses

#

the plugin should have nothing to do with it right?

knotty mist
#

yea

#

maybe u gotta add prints to debug it

#

can you send all the code in one message?

#

you can do that

keen dirge
#

like this?

knotty mist
#

nononono

#

remove the print

#

i will try to fix the code for you rq

keen dirge
#

I have no idea what im doing 🥲

knotty mist
#

did it print that?

#

on the output

#

when you open the game

keen dirge
#

no because i have a part named Door

#

should i try and remove it?

#

tried removing it nothing changed

knotty mist
#

where is your script at?

#

on the explorer

#

i tried doing the exact same things as yours and it could print

keen dirge
#

the fuse tracker or the main script?

knotty mist
#

and when you try to active the proximity prompt it were supposed to also send a message to the output

knotty mist
#

wait no

#

only the main script

#

i know your fuse tracker is at replicated storage

keen dirge
#

main script is located in the fusebox model

knotty mist
keen dirge
#

i frogot i also have a script called FuseCollectionHandler in serverscript service

#

ill send it here

knotty mist
#

send it

keen dirge
#

i cant send it??

knotty mist
#

what happens

keen dirge
#

Clyde says that i dont share a server with the recipent

knotty mist
#

tf

#

try sending it on my dms