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

Only special teams can spawn a vehicel?

Hello,

I have been trying to write a script for over 1 hour that only allows a special team to spawn a car, for example, the police are allowed to spawn police cars but the citizens are not.

This is what my script looks like, I only managed that everyone can spawn the car, but I didn't manage that, for example, only police officers can spawn police cars.

here my code:

script.Parent.MouseButton1Click: Connect (function (GetCar)
Mod = game.ServerStorage.VWPassat
clone = Mod: Clone ()
clone.Parent = workspace
clone: MakeJoints ()
end)

can anyone tell me how I can manage that, for example, police officers can spawn the VW Passat and all other teams cannot?

regards

1 comment

0

you can try to make a separate script that will only activate for the police team but not for the others

1 answer

✓ Accepted answer

alright so 3 things you need to do. 1) create a local script in the textbutton on the GUI. 2) create a remoteEvent in ReplicatedStorage name it as you wish. 3) create a script in serverScriptService

the localscript in with as parent the textButton

local rep = game:GetService("ReplicatedStorage")
local event = rep:FindFirstChild("YourEvent")--your RemoteEvent

script.Parent.MouseButton1Click:Connect(function()
	local plr = game.Players.LocalPlayer
	event:FireServer(plr)
end)

script in ServerScriptService

local rep = game:GetService("ReplicatedStorage")
local event = rep:FindFirstChild("YourEvent") --your RemoteEvent

local function CreateCar(plr)
	if plr.TeamColor  == BrickColor.new("White")-- your team color
	then
		local clone = game.ServerStorage:WaitForChild("VWPassat"):Clone()
		clone.Parent = game.Workspace
		clone:MakeJoints()
	else print("Not on the correct team")-- if you want an error message or something do it here
	end
end

event.OnServerEvent:Connect(CreateCar)

1 comment

0

Thank you so much! I Test it later because school! Thanks!

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