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!!
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.
-
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? -
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.
-
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) -
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!”) -
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