script.Parent.MouseButton1Click:connect(function()
-- Inside Server Script
local event = Instance.new("RemoteEvent") -- creates the event object
event.Parent = game.Workspace -- puts the event into the Workspace
event.Name = "MyServerEvent" -- giving a name to the event so we can fire it specifically elsewhere
event.OnServerEvent:connect(function() -- define the function that will be called when the event is fired
local player = script.Parent.Parent.Parent.Parent
local char = player.Character
local human = char:FindFirstChild("Humanoid")
local model = script.Parent.Parent.Model.Value
local car = script.Parent.Parent.Car.Value
if human:FindFirstChild(model)~= nil then
print("Model Found!")
if human:FindFirstChild(model):FindFirstChild(car) ~= nil then
print("Car Found!")
local body = human:FindFirstChild(model):FindFirstChild(car):GetChildren()
for i,v in pairs (body) do
if v.Name == "Seat" then
v.Disabled = true
script.Parent.Parent.Open.Visible = true
script.Parent.Visible = false
end
end
end
end
end)
game.Workspace.MyServerEvent:FireServer()
end)
this script works on studio but not on the roblox player. the error below pops up. why? please help 23:29:39.113 - OnServerEvent can only be used on the server 23:29:39.114 - Script 'Players.Player2.PlayerGui.VehicleGui.Lock.LocalScript', Line 6 23:29:39.114 - Stack End
