local player = game.Players.LocalPlayer
--all of this goes in a local script, which is in a part
script.Parent.Touched:connect(function(toucher)
if game.Players:FindFirstChild(toucher.Parent.Name) then
wait(0.5)
local a = math.random(1,25) --set the 100 to whatever number you want. setting it higher lowers the chance of getting pulled into a wild battle.
local b = math.random(1,1)--set the 1 on the right in the parenthesis to however many pokemon you would like to be in the grass.
print(a)
if a == 1 then
print("A Wild Pokemon Appeared!")--Not necessary, just shows that the script is working in the output. Remove this line if you want to.
if b == 1 then
player.PlayerScripts.CameraScript.Disabled = true
player.PlayerGui.BattleIntro.Frame1:TweenPosition(UDim2.new(0, 0, 0, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame2:TweenPosition(UDim2.new(0, 0, 0.1, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame3:TweenPosition(UDim2.new(0, 0, 0.2, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame4:TweenPosition(UDim2.new(0, 0, 0.3, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame5:TweenPosition(UDim2.new(0, 0, 0.4, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame6:TweenPosition(UDim2.new(0, 0, 0.5, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame7:TweenPosition(UDim2.new(0, 0, 0.6, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame8:TweenPosition(UDim2.new(0, 0, 0.7, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame9:TweenPosition(UDim2.new(0, 0, 0.8, 0), 'Out', 'Bounce', 1)
wait(0.1)
player.PlayerGui.BattleIntro.Frame10:TweenPosition(UDim2.new(0, 0, 0.9, 0), 'Out', 'Bounce', 1)
wait(1)
player.PlayerGui.Pokemon.Togepi.Visible = true
player.PlayerGui.BattleIntro.Frame1:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame2:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame3:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame4:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame5:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame6:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame7:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame8:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame9:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.BattleIntro.Frame10:TweenPosition(UDim2.new(0, 0, -1, 0), 'Out', 'Bounce', 1)
player.PlayerGui.Pokemon.Battle1.ImageTransparency = 0
wait(1)
player.PlayerGui.Pokemon.Frame:TweenPosition(UDim2.new(0, 0, 0, 0), 'Out', 'Bounce', 1)
wait(0.5)
player.PlayerGui.Pokemon.Battle1:TweenPosition(UDim2.new(0, 0,0.212, 0), 'Out', 'Quad', 1)
player.PlayerGui.Pokemon.Togepi:TweenPosition(UDim2.new(0.631, 0,0.363, 0), 'Out', 'Quad', 1)
player.PlayerGui.Pokemon.Fight:TweenPosition(UDim2.new(0, 0, 0.7, 0), 'Out', 'Back', 1)
wait(0.2)
player.PlayerGui.Pokemon.Bag:TweenPosition(UDim2.new(0.25, 0, 0.7, 0), 'Out', 'Back', 1)
wait(0.2)
player.PlayerGui.Pokemon.Switch:TweenPosition(UDim2.new(0.5, 0, 0.7, 0), 'Out', 'Back', 1)
wait(0.2)
player.PlayerGui.Pokemon.Run:TweenPosition(UDim2.new(0.75, 0, 0.7, 0), 'Out', 'Back', 1)
--If you want more than one pkemon to appear in the grass, then copy and paste the entire "if b ==1 then" statement and paste it under it and also change the value of b, which is all the way back at the top.
--Example of adding more pokemon:
---------------------------------
--if b == 2 then
--asset = ______
--model = game:GetService("InsertService"):LoadAsset(asset)
--model.Parent = game.workspace
--model:MakeJoints()
--model.Name = "MySecondPokemon"
--model.MoveTo(game.workspace.Grass.position)
--print(Hey, It's a MySecondPokemon!")
---------------------------------
end
end
end
end)
I've been modifying this script non-stop for 4 hours. I just figured out that the hecking thing doesn't work in game. It says things like 'Attempt to index LocalPlayer' or sometimes it doesn't work at all. Help please. ;-;

3 comments
Local scripts only work if they are a descendant of the player's Backpack, Playergui, Character, PlayerScripts or ReplicatedFirst. From what I can see, this is in a part in the workspace.
Local scripts are locally to the client (No contact to server) and to make a local script communicate with the server you will need to use remote events and remote functions and use server scripts, try and look at tutorials of filtering enabled on roblox.
I realize that mistake now. I was too tired to think at 2 am. Thanks guys!