Lots of questions

Oh boy, it’s me again! It’s me: the guy who decided to make a cliche simulator because I have no idea what I’m doing and it isn’t that complicated!
The problem? I’m making it complicated!! :laughing:
All right, so if you don’t have the time or patience to deal with me and my questions that are probably a lot simpler than I think, then you can just go on with your life.

  1. Parts and People
    Okay. So in multiple things that I’ve seen there are things like backpacks and weapons that are attached to the player. How would I do that? Obviously it has to do with cloning unions and models and such but I just can’t do it.
    Example: There is an animation for when you crouch down and pick up a stick or something. How would you make it so that the stick becomes attached to the player’s hand during the animation?

  2. I don’t like UI Text Labels.
    Another thing! I tried using Google to figure out this problem but it didn’t work for some reason so here I go. So I tried using this:

game.StarterGui.WhateverTheUiIsCalled.Textlabel.Text = NumberValue

but it didn’t work for some reason. I also would like to know how this works for Text Labels on Surface Gui’s, if it’s any different from this.

  1. Zone Things are Confusing
    Next up! So part of the game is selling things so that you can buy access to new areas, but how do I make it so that the area’s only open for players who have access to it?
    Example: You click a doorknob and open a door. The door only opens for the player who clicked the doorknob and not anyone else (unless they click the doorknob, of course)

  2. One-Time Events
    So I’m trying to make it so that the first time you talk to an NPC, they have different dialogue than the rest of the times you talk to them. How would this be possible?
    (Example: First time you talk to him: “Hi!” / Every other time: “Welcome back!”)

  3. Streamlining Things (Alternate Title: I’m bad at this)
    This is the code for function I mentioned in Question One:
    (Not sure why I split it into two scripts, because it broke the script)
    Script 1:

local part = script.Parent
local Clicked = script.Parent.ClickedOnce

local Players = game:GetService("Players")
local player = Players:GetPlayerFromCharacter(Players.Parent)

local function givePoints(player)
	if Clicked.Value == 0 then
		Clicked.Value += 1
		print("FUNCTION START!")
		
		player.Character.Humanoid.WalkSpeed = 0
		player.Character.Humanoid.JumpPower = 0
		
		wait(5)
		
		local playerStats = player:WaitForChild("leaderstats")
		local playerPoints = playerStats:WaitForChild("Sticks")
		local OakCount = player:WaitForChild("OakCount")
		
		playerPoints.Value += 1
		OakCount.Value += 1
		
		print("Oak count is ".. OakCount.Value)
		
		player.Character.Humanoid.WalkSpeed = 16
		player.Character.Humanoid.JumpPower = 50
		part:Destroy()
	elseif Clicked.Value >= 1 then
		wait(1)
	end
end

part.ClickDetector.MouseClick:Connect(givePoints)

Script 2: (PS The below code updates the in-game leaderboard, not a number value)

local part = script.Parent
local Clicked = script.Parent.ClickedOnce
local PopNoise = game.Workspace.PoppingNoise
local StickClicked = script.Parent.StickClicked
local Event = script.Parent.RemoteEvent

local Players = game:GetService("Players")
local player = Players:GetPlayerFromCharacter(Players.Parent)


local function TouchStick(otherPart)
	local partParent = otherPart.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid and StickClicked.Value == 1 then
		local Busy = player:WaitForChild("Busy")
		if Clicked.Value == 0 and Busy.Value == 0 then
		Event:FireClient(game.Players:GetPlayerFromCharacter(Players.parent))
		end	
	end	
end


local function EventFired()
	
			Clicked.Value += 1
			Busy.Value += 1
			
			print("FUNCTION START!")
			
			player.Character.Humanoid.WalkSpeed = 0
			player.Character.Humanoid.JumpPower = 0
			
			wait(5)
			
			local playerStats = player:WaitForChild("leaderstats")
			local playerPoints = playerStats:WaitForChild("Sticks")
			local OakCount = player:WaitForChild("OakCount")
			
			playerPoints.Value += 1
			OakCount.Value += 1
			
			print("Oak count is ".. OakCount.Value)
			
			player.Character.Humanoid.WalkSpeed = 16
			player.Character.Humanoid.JumpPower = 50
			Busy.Value -= 1
			PopNoise:Play()
			
			part:Destroy()
		elseif Clicked.Value >= 1 or Busy.Value == 1 then
			wait(1)
		end
	end
end

script.Parent.RemoteEvent.OnServerEvent:Connect(EventFired)

If you’re experienced, which you most likely are, you’d notice that there’re a bunch of problems. I tried using Number Values so that Players can’t click on other sticks while walking towards one, but that didn’t really work (PS it’s referenced as “Busy.Value”). Also, when you step on the part to activate Script 2, the function (used to) run multiple times before it actually started. I’m not really sure how to solve these, so I turn to you, random people who exist. I just want to streamline all of this messy code and, ya know, make it so it actually works.

Well, that’s it. I hope you guys can help me!
(You don’t have to if you don’t want to, though. Not sure why you read this far (or why I typed this far

1 Like
  1. I’m not sure about this, because i never personally used it, but probably it’s attached to the player.

  2. Try using NumberValue.Value, works with me when i do it.

  3. Maybe the player has a boolvalue that checks if they have access to open it, or something like this, developers can set if the player is allowed or not with this type of mechanic, this is my guess.

  4. If you are using a normal dialog, i would suggest using scripts to change the starting dialog.

(I didn’t get to finish 5)

I want to point out first that I am no way anything more than a beginner, but I will see if I can’t help you at least get a better idea of your issues. To anyone else, if I am wrong at any point, please immediately call it out. I do not want to spread misinformation. Now we can begin.

  1. No idea. That was easy.
  2. With this I assume you want it to update the GUI that the player is currently seeing. If this is true, then you must find that GUI within the player. For example,
local gui = game.Players.playername.PlayerGui:FindFirstChild("guiname"). 
  1. There are probably tons of ways to do this, obviously in varieties of difficulties. Here is a similar tutorial: Collisions | Documentation - Roblox Creator Hub

  2. You need to track whether or not the player has done it. I am not well experienced in proper programming techniques and habits, but I’d just make a tag. When the player talks to it for the first time, have it create a tag (IE a BoolValue object or something named haveTalked or something). Then have check to see if the player has that tag before it pops up the dialog. Look into the :FindFirstChild() some more for this.

  3. I am not good at reading code and finding errors, but someone else will be able to help with this.

Like I said, I am still learning. While I may not have the best habits yet, figuring out a way to do it is part of learning. As long as the task gets completed, you’re solid. After that is when you can work on improving how you did it.

1 Like
  1. You can use weld when animation plays, what i mean is use Touched event or try to find a timeline in the track animation using wait() inside it,try to find the keyframe you wanted in the animation editor and then weld the object you want to pick

  2. i dont understand the question

3.You can use CollisionGroup or PhysicsService

  1. Use BoolValue and Name it IsAlreadyTalked then store it in DataStore

  2. i never really use that