Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SERVICES
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- -- MODULES
- local Modules = ReplicatedStorage.Modules
- local GetAsset = require(Modules.GetAsset)
- -- REMOTES
- local Remotes = ReplicatedStorage.Remotes
- local EnterGrass = Remotes.EnterGrass
- -- PLAYER
- local Player = Players.LocalPlayer
- -- VARIABLES
- local Ran = Random.new()
- local EncounterAreas = workspace["Encounter Areas"]
- local Visuals = EncounterAreas.Visuals
- -- CODE
- function Start()
- for _, Grass in pairs(EncounterAreas.Hitboxes:GetDescendants()) do
- if Grass:IsA("BasePart") then
- local Size = Grass.Size
- local Position = Grass.CFrame
- local Rows = Size.X/4 -- X
- local Columns = Size.Z/4 -- Z
- local Corner = Position * CFrame.new((-Size.X/2) - 2, 0, (-Size.Z/2) - 2)
- for Column = 1, Columns do
- for Row = 1, Rows do
- local Visual = GetAsset("Grass")
- Visual.CFrame = Corner * CFrame.new(Row * 4, 0, Column * 4)
- Visual.CFrame = Visual.CFrame * CFrame.Angles(0, Ran:NextNumber(0, 1), 0)
- Visual.Parent = Visuals
- end
- end
- Grass.Touched:Connect(function(Hit)
- if Players:GetPlayerFromCharacter(Hit.Parent) == Player then
- if Hit.Name == "HumanoidRootPart" then
- EnterGrass:FireServer(Grass)
- end
- end
- end)
- end
- end
- end
- Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement