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

Script for making groups without friendly fire but doesn't work?

****This is a local script in a GUI on a filtering enabled game, I'm designing it for creating groups in which players can make so they don't accidentally kill each other, this script looks perfect to me and has no output errors, however, the ObjectValue is never created when I look.

function group()
	if script.Parent.crgroup.Text == "Create Group" then
		script.Parent.crgroup.text = "Disband Group"
		grouper = Instance.new("ObjectValue")
		grouper.Parent = game.Players.LocalPlayer
		grouper.Name = "GroupLeader"
		script.Parent.Invite.Visible = true
		script.Parent.NameInvite.Visible = true
	else
		local findgroup = game.Players.LocalPlayer:FindFirstChild("GroupLeader")
		if findgroup then
			findgroup:Destroy()
		end
	end
end

function inviteplayer()
	for i,v in ipairs(game.Players:GetChildren()) do
		if v.Name == script.Parent.NameInvite.Text then
			--to be continued
		end
	end
end

script.Parent.crgroup.MouseButton1Click:connect(group)
script.Parent.Invite.MouseButton1Click:connect(inviteplayer)

By the way, I am not good at scripting but have a semi general understanding.

1 comment

0

You need to create the group on the server and not on the local script.

1 answer

As kingdom5 says, you need to put some of this logic on the server.

LocalScripts (client code) should only deal with stuff that pertains to one person (especially a player's input and showing GUIs to that player). The server should be responsible for things that affect multiple players (and anything that you don't want a player to be able to mess with - ex, cash).

In case you're not familiar, here's a tutorial for Remote Events/Functions, which you'll need to have the GUI code tell the server code that the player wants to create a group and/or invite others to it.

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