I have planned to make something, a GUI that once clicked, shoots something. The only thing I want to make right now is a simple textbutton that says "click to shoot a ball", after that, It shoots a ball forward, and that's it.
This is the script.
LocalScript In StarterGui > ScreenGui > Textbutton
user = script.Parent.Parent.Parent script.Parent.TextButton.MouseButton1Click:connect(function() game.ReplicatedStorage.Events.TEST_SummonBal:FireServer(user) print("oh nice you shot a ball") --Just to make sure the FireServer worked. end)
Script in ServerScriptService
game.ReplicatedStorage.Events.TEST_SummonBal.OnServerEvent:Connect(function(user) local player = user.Character local Root = player:FindFirstChild("HumanoidRootPart") local Bullet = game.ReplicatedStorage.Weapons.BasicBullet:Clone() local MoveScript = game.ServerStorage.MoveScript:clone() --Movescript is Disabled, by the way. Bullet.Parent = game.Workspace MoveScript.Parent = Bullet --To make the Moving Part Script happen. Bullet.Position = Root.Position MoveScript.Disabled = false wait(3) Bullet:Destroy() end) --Sidenote: "Bullet" can't collide with the player.
It all seems to work, but one thing. I don't know how to make the "MoveScript", Which must, err...
You guys remember pokemon advanced?, The attacks worked in a way that they moved forward from the player, Here's a video example of that https://youtu.be/kefQj5vew6o?t=218 (Notice Persian's PayDay attack)
That's what I want the movescript to do, However, I don't know how to make it.
You can give me a hand, right?
If you're going to be those persons and right out just post the script, AT LEAST Explain me how it works, I won't learn anything if you don't teach me.
Hey Chris75764,
-- Local Script under StarterGui local uis = game:GetService("UserInputService") -- The UserInputService to detect input. local players = game:GetService("Players") -- Players service local player = players.LocalPlayer -- The player that the script is under. uis.InputBegan:Connect(function(obj, gp) -- Anonymous function with the input and gameProcessed event as arguments. if obj.KeyCode == Enum.KeyCode.Q and not gp then -- Checks if the player pressed 'Q' and if it was pressed while typing in chat or meant to be pressed. local part = Instance.new("Part") -- Makes a part -- Property preferences -- part.BrickColor = BrickColor.Random() part.Transparency = math.random() part.Size = Vector3.new(5, 5, 5) part.Shape = Enum.PartType.Ball -- Property preferences -- local char = player.Character -- The character of the player local root = char:WaitForChild("HumanoidRootPart") -- The HumanoidRootPart of the player part.CFrame = root.CFrame * CFrame.new(0, 0, -3) -- Spawns the part 3 studs in front of the character's humanoid. local bv = Instance.new("BodyVelocity") -- Makes the body velocity object. bv.Parent = part -- Parents it to the part bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge) -- Sets its maxForce to infinity bv.Velocity = root.CFrame.lookVector * 100 -- Makes it move forward at a speed of 100. part.Parent = workspace -- Parents the part to workspace. end end)
Thanks,
Best regards,
KingLoneCat