Hey !
I’m trying to make an SCP-914 for my SCP game. Since I use a server script to determine the position of the button, or if a player used the button, I tried to use game:GetService(“Players”) to detect the player (inventory, character, health…) But I get an error : Character is not a valid part of workspace, here is the code :
script.Parent.ClickDetector.MouseClick:Connect(function()
local cs = script.Parent.Parent.Button.TurnScript
local part = script.Parent.Parent.Parent.Model.InputDoor
local partbis = script.Parent.Parent.Parent.Model.OutputDoor
local SS = game.ServerStorage
cs.Disabled = true
script.Parent.ClockworkSound:Resume()
local player = game:GetService("Players")
local card0 = game:GetService("Players").Character:FindFirstChild("[SCP] Card-L0")
local card1 = game:GetService("Players").Character:FindFirstChild("[SCP] Card-L1")
local card2 = game:GetService("Players").Character:FindFirstChild("[SCP] Card-L2")
local card3 = game:GetService("Players").Character:FindFirstChild("[SCP] Card-L3")
local card3b = game:GetService("Players").Character:FindFirstChild("[SCP] Guard")
local card4 = game:GetService("Players").Character:FindFirstChild("[SCP] Site Director")
local card4b = game:GetService("Players").Character:FindFirstChild("[SCP] MTF")
local card4c = game:GetService("Players").Character:FindFirstChild("[SCP] UIU")
local card4d = game:GetService("Players").Character:FindFirstChild("[SCP] GOC")
local card5 = game:GetService("Players").Character:FindFirstChild("[SCP] Card-L5")
local card5bis = game:GetService("Players").Character:FindFirstChild("[SCP] Alpha-1")
local cardb = player.Character:FindFirstChild("[SCP] Bypass")
script.Parent.Parent.Parent.Input.Detection.Touched:Connect(function(p)
local place = CFrame.new(-17.375, 5.6, -3.705)
local humanoid = p.Parent:findFirstChild("Humanoid")
local Mode = game.ReplicatedStorage.Scp914Mode
if Mode.Value == 1 then
player.Character:FindFirstChildWhichIsA("Tool"):Destroy()
wait(12)
humanoid.Torso.CFrame = place
humanoid.Health = 0
elseif Mode.Value == 2 then
if card0 then
card0:Destroy()
elseif card1 then
card1:Destroy()
local n0 = SS.AccessCard["[SCP] Card-L0"]:Clone()
n0.Parent = player.Character
elseif card2 then
card2:Destroy()
local n0 = SS.AccessCard["[SCP] Card-L1"]:Clone()
n0.Parent = player.Character
elseif card3 then
card3:Destroy()
local n0 = SS.AccessCard["[SCP] Card-L2"]:Clone()
n0.Parent = player.Character
elseif card4 then
card4:Destroy()
local n0 = SS.AccessCard["[SCP] Card-L3"]:Clone()
n0.Parent = player.Character
elseif card5 then
card5:Destroy()
local n0 = SS.AccessCard["[SCP] Site Director"]:Clone()
n0.Parent = player.Character
elseif card5bis then
card5bis:Destroy()
local n0 = SS.AccessCard["[SCP] Site Director"]:Clone()
n0.Parent = player.Character
elseif cardb then
cardb:Destroy()
local n0 = SS.AccessCard["[SCP] Guard"]:Clone()
n0.Parent = player.Character
end
wait(12)
humanoid.Torso.CFrame = place
humanoid.Health = humanoid.Health/2
elseif Mode.Value == 3 then
wait(12)
humanoid.Torso.CFrame = place
elseif Mode.Value == 4 then
if card0 then
card0:Destroy()
local n0 = SS.AccessCard["[SCP] Card-L1"]:Clone()
n0.Parent = player.Character
elseif card1 then
card1:Destroy()
local n0 = SS.AccessCard["[SCP] Card-L2"]:Clone()
n0.Parent = player.Character
elseif card2 then
card2:Destroy()
local n0 = SS.AccessCard["[SCP] Card-L3"]:Clone()
n0.Parent = player.Character
elseif card3 then
card3:Destroy()
local n0 = SS.AccessCard["[SCP] Site Director"]:Clone()
n0.Parent = player.Character
elseif card4 then
card4:Destroy()
local n0 = SS.AccessCard["[SCP] Card-L5"]:Clone()
n0.Parent = player.Character
elseif card5 then
card5:Destroy()
local n0 = SS.AccessCard["[SCP] Site Director"]:Clone()
n0.Parent = player.Character
elseif card5bis then
card5bis:Destroy()
local n0 = SS.AccessCard["[SCP] Site Director"]:Clone()
n0.Parent = player.Character
elseif cardb then
cardb:Destroy()
local n0 = SS.AccessCard["[SCP] Site Director"]:Clone()
n0.Parent = player.Character
end
wait(12)
humanoid.Torso.CFrame = place
humanoid.Health = humanoid.Health + 20
elseif Mode.Value == 5 then
wait(12)
humanoid.Torso.CFrame = place
humanoid.Health = 0
humanoid.BreakJointsOnDeath = false
end
end)
end)
And reference that player since you can’t get the Character from a list of players like that.
Also, if you’re trying to replicate scp 914, can’t you use FindPartsInRegion3 to determine the parts in the Input area, do something for the Output area with that info?
You are doing this completely wrong, you are checking if the player has an equipped tool instead you should check for the tools on the ground or in their backpack.
After which you should switch the improved tools with the current tools with each other.
As well as not using the player parameter from the ClickDetector connection like @EmbatTheHybrid explained, instead you made a variable called player which is equal to the Players Service.
Instead I highly suggest putting a region3 inside the room where you drop the tools, make the region3 a bit bigger than the room itself you will then find all parts inside the region3 with FindPartsInRegion3, then you delete the cards inside the region3 and spawn the “improved cards” inside the other room. When you do this you can save the middle of room1 and room2 then you use CFrame to object and world space to move the tools from the 1 room to another room.
Robbery makes any game funner, it is about deceiving people and getting a benefit out of it. Most people enjoy getting a benifit from other people and either way last times I played any type of SCP game with SCP-914 most people kept their deginity and followed the person with the keycard and never stole it, even when he was upgrading it.
Any SCP game should be about teamwork so you should test your players further in the game, if they can not play as a team they will never win nor succeed.
My point being there is more risk if people can steal it, more risk correlates with the game being more fun, why else are people addicted to gambling, because of the risk.
If you want to discuss this further I rather move this to direct messages.
I highly suggest not using OnTouched, in the past I used OnTouched and only if a card is for example in the doorway it will still run, instead create a region3 from the room space this can be done by converting a part instance to region3 like so:
local roomPart = -- Path to room part, this will be a bit bigger than the room
local reg3 = Region3.new(Vector3.new(), Vector3.new())
reg3.Size = roompart.Size
reg3.CFrame = roompart.CFrame
After creating a region3 you will make a function you will run every time to check for all parts inside the room, we will be using workspace:FindPartsInRegion3:
local function getToolsInRoom()
local parts = workspace:FindPartsInRegion3(reg3, nil, 20)
local tools = {}
for _, part in pairs(parts) do
local tool = part.Parent
if tool:IsA("Tool") then
table.insert(tools, tool)
end
end
return tools
end
You can receive all the tools by doing the following:
local tools = getToolsInRoom()
Then you will loop through all tools and replace all of them like so:
for _, tool in pairs(tools) do
if tool.Name == "[SCP] Card-L0" then
tool:Destroy()
elseif tool.Name == "[SCP] Card-L1" then
local rTool = SS.AccessCard["[SCP] Card-L0"]:Clone() -- Replacement for the current tool
rTool.Parent = workspace
-- move the rTool inside room 2 with the offset of tool in room 1
-- You can do this with CFrame Object and World Space, which I linked in a post before.
tool:Destroy()
-- even more elseif statements
end
end
I’m trying to make it automatic, instead of doing manually everytime every possibility
Should I Put items in a table (like Card-L3) and if the player put on Fine, it’ll get a random item on the table a level above (L4) and replace it.
Same thing for like coarse or stuff like that.
– Edit –
If I need to do it manually, imma do it, it’s just to know
Have all the cards in order (worst to best cards) in a table
Manually, it is kinda like shown above but more text.
Have some complex system which will decide what can happen with every specific card it’ll use a module script and start looking something like shown below first, after you will put every type of card inside every setting and equal it to a table with what the card can be. I do not recommend doing this.