Hi there, i have a problem with my scripts. what is supposed to happen is that the first script parents a folder to serverstorage and parents a clone of another folder from server storage to workspace. That part works but the scripts inside the other folder doesn't work. The scripts work when i test them without them being in serverstorage. but once they are in server storage they don't work. Can anyone help?
Sorry If i poorly explained this
EDIT: i found out the problem, the proximity prompts wouldn't be registered by the scripts
Sorry If i poorly explained this
EDIT: i found out the problem, the proximity prompts wouldn't be registered by the scripts
Script that handles the folders
Code:
game:GetService('ReplicatedStorage').Remotes.ChangeMaps.OnServerEvent:Connect(function()
-- parents old parts of facility to server storage
for _, parts in pairs(workspace.Facility:GetChildren()) do
parts.Parent = game:GetService('ServerStorage').Facility
end
-- clones new parts and adds them to workspace
local brofacclone = game:GetService('ServerStorage').BrokenFacility:Clone()
for _, parts in pairs(brofacclone:GetChildren()) do
parts.Parent = workspace.BrokenFacility
end
-- turns on barrier and changes lighting
workspace.Barriers.Noexit.CanCollide = true
game:GetService('Lighting').Ambient = Color3.fromRGB(70,70,70)
task.wait(3)
-- turns on all script
for _, parts in pairs(brofacclone:GetDescendants()) do
if parts:IsA('Script') then
parts.Enabled = true
end
end
-- fires remoteevent
game:GetService('ReplicatedStorage').Remotes.MapLoaded:FireAllClients()
end)
Scripts inside the other folder
Code:
local keypad = script.Parent:FindFirstChild('keypad')
local keypad2 = script.Parent:FindFirstChild('keypad2')
local tween = game:GetService('TweenService')
local door = script.Parent:FindFirstChild('Door')
local doorvalue = script.Parent:FindFirstChild('DoorValue')
local debounce = false
keypad.ProximityPrompt.Triggered:Connect(function()
keypad.Beep:Play()
if debounce == false then
if doorvalue.Value == true then
debounce = true
wait(.2)
door.Door:Play()
tween:Create(door, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Position = Vector3.new(door.Position.X, door.Position.Y + 6.5, door.Position.Z)}):Play()
doorvalue.Value = false
wait(2)
debounce = false
elseif doorvalue.Value == false then
debounce = true
wait(.2)
door.Door:Play()
tween:Create(door, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Position = Vector3.new(door.Position.X, door.Position.Y - 6.5, door.Position.Z)}):Play()
doorvalue.Value = true
wait(2)
debounce = false
end
end
end)
keypad2.ProximityPrompt.Triggered:Connect(function()
keypad2.Beep:Play()
if debounce == false then
if doorvalue.Value == true then
debounce = true
wait(.2)
door.Door:Play()
tween:Create(door, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Position = Vector3.new(door.Position.X, door.Position.Y + 6.5, door.Position.Z)}):Play()
doorvalue.Value = false
wait(2)
debounce = false
elseif doorvalue.Value == false then
debounce = true
wait(.2)
door.Door:Play()
tween:Create(door, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Position = Vector3.new(door.Position.X, door.Position.Y - 6.5, door.Position.Z)}):Play()
doorvalue.Value = true
wait(2)
debounce = false
end
end
end)
Code:
local gun = script.Parent.Parent:FindFirstChild('AR-15')
script.Parent.Attachment.ProximityPrompt.Triggered:Connect(function(plr)
local char = plr.Character
local backpack = plr.Backpack
if char:FindFirstChild('HasPrimaryWeapon').Value == false then
char:FindFirstChild('HasPrimaryWeapon').Value = true
gun.Parent = backpack
gun.Handle.Anchored = false
script.Parent.Sound:Play()
script.Parent.Attachment.ProximityPrompt.Enabled = false
wait(1)
script.Parent.Parent:Destroy()
end
end)