You see it all the time in roblox gun games and I want to recreate this for my game. When a player spawns in, I want them to be completely unkillable by other players. I have looked on google for a tutorial, and had no luck. Thanks to anyone who knows how to do this and can help me out!
(I also want the player to be partly transparent in their unkillable state if that isn’t asking for too much!)
It’s not a specific space that the player spawns in, (bc players spawn randomly over the map) rather not killing them until they start moving. ngl, im pretty bad at scripting so I don’t know how to do that. something to do with userinputservice idk lol
So instead of just a timer setup you could make a check to see if the player has moved, then when they do move give them a few seconds with the timer so other players don’t immediately get a chance to spawn kill.
Always try the search bar up top as well as Google.
I used the Search bar with the term ‘check if player moved’ and got a few results with some of them showing as Solved. You can try using the Force Field page scripts with the other kinds of scripts to give the effect you want.
You could parent a ForceField object to a player’s character, then connect a function with the Heartbeat property of RunService to constantly check the player’s PrimaryPart position. Let me know if that helps!
This is probably overcomplicated since I’m not a very good scripter but you could do “repeat(set player health to 100) until w or a or s or d buttons are pushed”
I don’t know Lua so I can’t tell you how to write that in the syntax but I hope this helps.
Add an invisible Forcefield, or keep it visible if you like, upon CharacterAdded. Remove it when MoveDirection is set in the Humanoid. You should also only let guns work once you move.
game:GetService("Players").CharacterAdded:Connect(function(char)
local Forcefield = Instance.new("Forcefield")
Forcefield.Visible = false
Forcefield.Parent = char
char:WaitForChild("Humanoid").Changed:Connect(function(property)
if property == "MoveDirection" then
char:FindFirstChild("Humanoid").Changed:Disconnect()
task.wait(5)
Forcefield:Destroy()
--enable weapons here
end
end
end
The code is made on my phone and untested, and it’s currently unsage to test as my laptop fan died.
EDIT: Apparently someone else posted code similar to mine while I was typing. Theirs looks better anyway lol