local Model = script.Parent local SafeZoneDetector = Model:WaitForChild("SafeZoneDetector") SafeZoneDetector.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") and hit.Parent:FindFirstChild ("SafeZone Protection") == nil then local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) game.Players.LocalPlayer.PlayerGui.ScreenGui.safed.Visible = true local Forcefield = Instance.new("ForceField") Forcefield.Name = "SafeZone Protection" Forcefield.Visible = false Forcefield.Parent = hit.Parent end end) SafeZoneDetector.TouchEnded:Connect(function(hit) game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true local object = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame object:TweenSize(UDim2.new(0, 0, 0, 0), nil, nil, 60) wait (60) if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") and hit.Parent:FindFirstChild ("SafeZone Protection") == nil then hit.Parent:FindFirstChild("SafeZoneProtection"):Destroy() end end)
? made this safe zone script but it wont work and ? am not able to see any erors in output any help please
This script is stored in a model that contains the safe-zone, but it's a LocalScript? Part of your script handles the ForceField, and another part handles the GUI. This isn't possible from one script (the ForceField would be local). What you need to do is separate it into two scripts.
Script inside model:
local Model = script.Parent local SafeZoneDetector = Model.SafeZoneDetector SafeZoneDetector.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") and hit.Parent:FindFirstChild ("SafeZone Protection") == nil then local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) game.Players.LocalPlayer.PlayerGui.ScreenGui.safed.Visible = true local Forcefield = Instance.new("ForceField") Forcefield.Name = "SafeZone Protection" Forcefield.Visible = false Forcefield.Parent = hit.Parent end end)
LocalScript anywhere where LocalScripts run:
local Model = Path.To.Model local SafeZoneDetector = Model:WaitForChild("SafeZoneDetector") SafeZoneDetector.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") and hit.Parent:FindFirstChild ("SafeZone Protection") == nil then local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if player == game.Players.LocalPlayer then game.Players.LocalPlayer.PlayerGui.ScreenGui.safed.Visible = true end end end) SafeZoneDetector.TouchEnded:Connect(function(hit) game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true local object = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame object:TweenSize(UDim2.new(0, 0, 0, 0), nil, nil, 60) end)
Please excuse any typing mistakes I make, I'm writing this on mobile