So I wanted to make a thing where after reaching a certain spot new objects will appear, I manage to do one bit but it only does it when you join the game, and I would like it to appear after touching a certain part not when you join the game.
If its 1 part then this will be the code:
Local trigger = [Locate your trigger here] trigger.Touched:Connect(function(h) -- This will start the function whenever its touched! if game.Players:GetPlayerFromCharacter(h.Parent) then -- This will make sure its actually a player thats triggered it, rather then something else. -- Your code here end end
If you require to run any code on the character, use h.Parent - This should return the character. If its a model, create a sort of hit box on the floor. Put that as the trigger.
I recommend using .hit like
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild ('Humanoid') then if hit.Parent:FindFirstChild ('Humanoid').Health ~= 0 then local player = game.Players:GetPlayerFromCharacter(hit.Parent) game.ReplicatedStorage.Remotes.OpenPetShop:FireClient(player) end end end)
is what I used