Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Only special teams can spawn a vehicel?

Asked by 4 years ago

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

0
you can try to make a separate script that will only activate for the police team but not for the others Retallack445 75 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
0
Thank you so much! I Test it later because school! Thanks! ExperienceHP 0 — 4y
Ad

Answer this question