use humanoid:TakeDamage(100)
instead
Yeah. i am trying to clone an obby that has a few kill bricks, and a teleporter part in it. Both of these things work when I put them into the workspace, but they are not clones, but when they are cloned from lighting or replicated storage, they dont work.
Can we see your code? I understand your concept but we can’t help you debug if you don’t give us the code.
lighting is not a place you should store obbies in
Sure, which one would you like to see the kill script or the clone script?
Actually both would be better if you can do that
Sure, here they are:
here is the kill script:
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Health = h.Health-100
end
end
script.Parent.Touched:connect(onTouched)
teleport;
--it was orignally replicated storage bellow, but I am trying to figure out where I should put it
local ObbiesFolder = game.Lighting:FindFirstChild("Obbies")
local TextBox = script.Parent.Parent.TextBox
ObbyAlreadySpawned = false
local obby = nil
script.Parent.MouseButton1Down:connect(function ()
if obby then
obby:Destroy()
end
Obby = ObbiesFolder[TextBox.Text]:Clone()
Obby.Parent = game.Workspace
ObbyAlreadySpawned = true
end)
and you’re cloning the obby with a server script correct ?
(you should be using ReplicatedStorage, Lighting was used years ago when we didn’t have that luxury haha)
Is your teleport script a LocalScript or a normal Script?
When you clone something from ReplicatedStorage on the client (read: from a local script), the server scripts don’t run. The server doesn’t actually know you cloned it, because it’s on the client.
Additionally, if your kill script is a localscript, it won’t run in the workspace. It must be parented to PlayerGui/PlayerScripts etc.
You can use CollectionService on the client to fix your issue.
lol, I told him to put it in Lightning and it did not solve the problem.
My TP script is a local script because I wanted the players to be able to do spereate obbies at the same time. How would I use the CollectionService thing?
bruh… the solution was already given long time ago, i sent the collectionservice documentation already AND TOLD you you needed to clone on server side
musnt have read that one then, can you send it again? and I the thing about putting that clone in the workspace wouldnt work because I am goingto make multiple obbies and I would have to do that everysingle time
He does not want to clone it on the server.
then there’s a big mistake in conception of your game in the first place, you’d have to make the whole obby local, including the kill brick scripts, and then again i don’t know if that’d work
Ya, the players get to choose the obby and it would not be fun if all the players needed to choose one obby.
nevermind, just get a localscript in starterplayer that handles every newly spawned killbricks (because localscripts do not run in workspace)
Here is a kill brick script:
local player = game.Players.LocalPlayer
function onTouched()
player.Character.Humanoid.Health = 0
end
script.Parent.Touched:Connect(onTouched)
CollectionService allows you to define logic for objects without putting scripts in them. The general idea is to have 1 script handling all kill parts (in your case).
You need to use the Tag Editor window:
From here, you need to create a tag. You can name it anything you’d like, I’ll name it KillPart
(you write the name in the “New Tag” field and press enter to make a new tag)
Now you have to tag your kill part. You can do that in ReplicatedStorage - when you :Clone() something, you clone the tags as well. That’s why its so convenient!
Select your part and tick the tag.
Now its time to write a script. I’m going to write a LocalScript which kills the local player when a part with the tag is touched. This goes in StarterPlayer.StarterPlayerScripts:
--!strict
--// Services
local CollectionService = game:GetService("CollectionService")
--// Constants
local TAG_NAME = "KillPart"
--// Code
workspace.DescendantAdded:Connect(function(instance)
-- This code runs every time something gets added to the workspace
if CollectionService:HasTag(instance, TAG_NAME) then
-- This code runs if the "something" has the KillPart tag
instance.Touched:Connect(function(other)
local hum = other.Parent:FindFirstChild("Humanoid")
if hum then
hum:TakeDamage(hum.MaxHealth)
end
end)
end
end)
This is the gist of it. A player can safely :TakeDamage() on themselves, so replication isn’t an issue and you don’t need a server script.
Note: you no longer need the individual kill scripts on each kill part. This is neat: you can change the code for all kill parts from a single script. This is what makes CollectionService so powerful, and is the exact same reason people use ModuleScripts.
How many parts can you select for one tag?