So far I've only been able to do this with local scripts and not with regular ones. I want to make a forcefield-like wall inside of my vehicle that can be enabled and disabled with a certain key. LocalPlayer doesn't seem to exist inside of regular scripts. Is there a way around this?
Seats have a Property called Occupant you can check if it changed and see if its not nil then you would want to clone a local script to the players Gui now you need to assign a special name or just store it in a variable but i just store it in a name like the generateUUID function of HttpsService
local Seat = Script.Parent Seat:GetPropertyChangedSignal("Occupant"):Connect(function() local Hum = Seat.Occupant if Hum then RandomName = game:GetService("HttpService"):GenerateGUID() local Player = Players:GetPlayerFromCharacter(Hum.Parent) local C = script.LocalScript:Clone() C.Parent = Player C.Boat.Value = Seat.Parent C.Name = RandomName end if Hum == nil then Players:FindFirstChild(tostring(RandomName),true):Destroy() end end)
local seat = script.Parent seat:GetPropertyChangedSignal("Occupant"):Connect(function() local hum = seat.Occupant if hum then local player = game.Players:GetPlayerFromCharacter(hum.Parent) local name = player.Name local p = game.Players:WaitForChild(name) local dee = game.Players.."."..name local mouse = dee:GetMouse() mouse.KeyDown:Connect(function(key) if key == "F" then local b = Instance.new("Part") b.Parent = workspace end end) end end)
This is what I have right now It's telling me "Attempt concatenate Instance with string"