Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How could I replicate this feature?

When I tried CloneTrooper1019's Murder game a while ago, one thing that was personally my favorite feature was when if you collect 5(?) gems(?) you would get a gun.

That was my favorite feature because it makes teaming and gun guarding pointless and the game more fun.

Now, I'm making a murder game using the Mad Bloxxer Template (from RBLX University), (since I only know the basics of scripting) and I really want to include that feature in the game.

But, as you know, I'm a noob at scripting, so that's why I need help on how it works. (Please explain step by step) Thank you for reading.

When I posted this at RBLX forums, someone replied with this, which I really didn't understand most of it.

game.Workspace.Gem.Touched:connect(function(hit)
	if hit.Parent.ClassName == Character then else return end; -- checks if player if not returns nil
	local name = hit.Parent.Name;
	Players[name].GemValue = Players[name].GemValue + 1;
end)

-- in gem value
script.Parent.Changed:connect(function()
	if script.Parent.Value == 5 then
		script.Parent.Value = 0;
		award_gun();
	end
end)

1 answer

Here is an explanation of the script. I have no clue how your game is set up so this is all I can do for you right now.

game.Workspace.Gem.Touched:connect(function(hit) -- This defines the function that is played out when a gem is touched. The function is the code below until end)
    if hit.Parent.ClassName == Character then else return end; -- this checks if it was a player that touched the gem
    local name = hit.Parent.Name; -- this is a variable everywhere that name is used the script interprets it as hit.Parent.Name which is the name of the player that touched it.
    Players[name].GemValue = Players[name].GemValue + 1; -- Takes the player that touched it and adds to the gem value.
end)

-- in gem value
script.Parent.Changed:connect(function() -- another function
    if script.Parent.Value == 5 then -- if the Gem Value is 5
        script.Parent.Value = 0; -- then make the gem value 0
        award_gun(); -- and give the player a gun
    end
end)


I have no idea if this script is working because again I don't know how your game is currently set up at all so that is the most I can do.

2 comments

0

Thanks for the explanation, but how does the set up of the game effects this?

0

I don't know where Gem is at, the script claims it is in workspace. I don't know where the script is located, so I don't know what the script's parent is. I don't know how your game is set up, which affects where the script looks for things to interact with.

This discussion is preserved as it was. New answers, comments, and votes are closed.