Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
4

Help with alvinblox script please idk what"s happening? [closed]

Asked by
starmaq 1290 Moderation Voter
4 years ago

Please provide code with your answers. Simply posting an explanation does not help someone new to programming understand how to implement a concept programatically.

So I have this alvinblox script

local serverStorage = game:GetService(“ServerStorage”)
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local KOValue = “Kills”
local WOValue = “Wipeouts”
local damage = 30
replicatedStorage.ShootEvent.OnServerEvent:Connect(function(player,tool,position,part)
if game.Workspace[player.Name].Humanoid.Health <= 0 then
— The player is dead, do not do anything
else
local distance = (tool.Handle.CFrame.p – position).magnitude
if game.Workspace:FindFirstChild(player.Name..“‘s Trajectory”) then
game.Workspace:FindFirstChild(player.Name..“‘s Trajectory”):Destroy()
end
local trajectory = Instance.new(“Part”,game.Workspace)
local smoke = serverStorage.SmokeParticle:Clone()
smoke.Parent = tool.Handle
trajectory.BrickColor = BrickColor.new(“Institutional white”)
trajectory.Material = “SmoothPlastic”
trajectory.Name = player.Name..“‘s Trajectory”
trajectory.Transparency = 0.5
trajectory.Anchored = true
trajectory.Locked = true
trajectory.CanCollide = false
trajectory.Size = Vector3.new(0.3,0.3,distance)
for i = 0,distance,6 do
trajectory.CFrame = CFrame.new(tool.Handle.CFrame.p,position) * CFrame.new(0,0,-distance / 2)
wait(0.0001)
end
smoke:Destroy()
if part then
if part.Name == “Head” or part:IsA(“Hat”) and part.Parent:FindFirstChild(“Humanoid”).Health > 0 then
— Boom headshot
replicatedStorage.Headshot:FireClient(player)
damage = 50
end
local humanoid = part.Parent:FindFirstChild(“Humanoid”)
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild(“Humanoid”)
else
humanoid:TakeDamage(damage)
if humanoid.Health <= 0 then
player.leaderstats[KOValue].Value = player.leaderstats[KOValue].Value + 1
game.Players[humanoid.Parent.Name].leaderstats[WOValue].Value = game.Players[humanoid.Parent.Name].leaderstats[WOValue].Value + 1
end
end
wait(0.25)
if trajectory then
trajectory:Destroy()
end
end
end
end)

replicatedStorage.EquipAnimation.OnServerEvent:Connect(function(player,animation)
local newAnim = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
newAnim:Play()
replicatedStorage.UnequipAnimation.OnServerEvent:Connect(function(player,animation)
newAnim:Stop()
for i,v in pairs(game.Workspace:GetChildren()) do
if v.Name == player.Name..“‘s Trajectory” then
v:Destroy()
end
end
end)
replicatedStorage.Reload.OnServerEvent:Connect(function(player,animation)
newAnim:Stop()
local reloadAnim = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
reloadAnim:Play()
end)
end)

function checkBodyType(player,tool)
if game.Workspace[player.Name]:FindFirstChild(“LowerTorso”) then — R15
tool.shoot.AnimationId = “rbxassetid://936531673”
tool.reload.AnimationId = “rbxassetid://937806099”
return “R15”
end
if game.Workspace[player.Name]:FindFirstChild(“Torso”) then — R6
tool.shoot.AnimationId = “rbxassetid://1000874313”
tool.reload.AnimationId = “rbxassetid://937933712”
return “R6”
end
end
replicatedStorage.CheckBodyType.OnServerInvoke = checkBodyType

— Local Script, which goes inside the tool

local tool = script.Parent — Getting the tool
local player = game:GetService(“Players”).LocalPlayer — Getting the player
local mouse = player:GetMouse() — Getting the mouse
local sound = tool:WaitForChild(“Gunfire”)
local torso = “” — Nothing for now.
local reloading = false — Variable to check if we are currently reloading
local contextActionService = game:GetService(“ContextActionService”) — Allow us to cater for Mobile players
local bodytype = nil — Nil for now but will check whether player is R6 or R15
local difference = 0 — Difference between position of head and mouse
local replicatedstorage = game:GetService(“ReplicatedStorage”)
local gungui = tool:WaitForChild(“GunGUI”)
local bullets = tool:WaitForChild(“Bullets”)
local reloadtime = 3
— Remote Events
local equipAnimation = replicatedstorage:WaitForChild(“EquipAnimation”)
local headshot = replicatedstorage:WaitForChild(“Headshot”)
local reload2 = replicatedstorage:WaitForChild(“Reload”)
local shootevent = replicatedstorage:WaitForChild(“ShootEvent”)
local unequipanimation = replicatedstorage:WaitForChild(“UnequipAnimation”)
— Remote Functions
local checkBodyType = replicatedstorage:WaitForChild(“CheckBodyType”)
local fetchBulletsLeft = replicatedstorage:WaitForChild(“FetchBulletsLeft”)
— Find Body Type
function findBodyType() — Used to determine whether a player is R6 or R15
bodytype = checkBodyType:InvokeServer(tool) — Invoking the Remotefunction to do a check on the server
print(bodytype)
end
— Reloading function
function reload()
reloading = true
reload2:FireServer(tool.reload)
mouse.Icon = “http://www.roblox.com/asset?id=936489163”
player.PlayerGui:WaitForChild(“GunGUI”).Bullets.Text = “Reloading!”
wait(reloadtime)
bullets.Value = 6
player.PlayerGui:WaitForChild(“GunGUI”).Bullets.Text = “Bullets: “..bullets.Value
mouse.Icon = “http://www.roblox.com/asset?id=936803874”
equipAnimation:FireServer(tool.shoot)
reloading = false
end
— When the tool is equipped, the following event will run
tool.Equipped:Connect(function(mouse)
gungui:Clone().Parent = player.PlayerGui — We are cloning the Gun GUI into the player’s PlayerGUI
findBodyType() — Calling the function above to check the body type.
equipAnimation:FireServer(tool.shoot) — Calling the equip animation remoteevent so that the server can play the animation
mouse.Icon = “http://www.roblox.com/asset?id=936803874”
mouse.Button1Down:Connect(function()
if bullets.Value <=0 or reloading == true then
— Don’t do anything
else
local head = game.Workspace[player.Name].Head.CFrame.lookVector
local mouse = CFrame.new(game.Workspace[player.Name].Head.Position,mouse.Hit.p).lookVector
difference = (head–mouse)
local ray = Ray.new(tool.Handle.CFrame.p,(player:GetMouse().Hit.p – tool.Handle.CFrame.p).unit*300)
local part,position = game.Workspace:FindPartOnRay(ray,player.Character,false,true)
sound:Play()
if difference.magnitude < 1.33 then
shootevent:FireServer(tool,position,part)
bullets.Value = bullets.Value – 1
end
end
end)
local reloadMobileButton = contextActionService:BindAction(“ReloadBtn”,reload,true,“r”)
contextActionService:SetPosition(“ReloadBtn”,UDim2.new(0.72,–25,0.20,–25))
contextActionService:SetImage(“ReloadBtn”,“http://www.roblox.com/asset/?id=10952419”)
end)
tool.Unequipped:Connect(function()
mouse.Icon = “”
unequipanimation:FireServer(tool.shoot)
player.PlayerGui.GunGUI:Destroy()
contextActionService:UnbindAction(“ReloadBtn”)
end)
headshot.OnClientEvent:Connect(function()
player.PlayerGui.GunGUI.Headshot:TweenPosition(UDim2.new(0.5,–100,0.5,–25), “Out”,“Quint”,0.3)
wait(1.5)
player.PlayerGui.GunGUI.Headshot:TweenPosition(UDim2.new(–1,0,0.5,–25), “In”,“Quint”,0.4)
wait(0.5)
player.PlayerGui.GunGUI.Headshot.Position = UDim2.new(1.5,0,0.5,–25)
end)


— Leaderboard code which goes inside ServerScriptService, optional to include, you can add your own if you want but bear in mind the gun won’t work unless you have some sort of leaderboard with a Kills and Wipeouts stat

game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“IntValue”,player)
leaderstats.Name = “leaderstats”

local kills = Instance.new(“IntValue”,leaderstats)
kills.Name = “Kills”
kills.Value = 0

local wipeouts = Instance.new(“IntValue”,leaderstats)
wipeouts.Name = “Wipeouts”
wipeouts.Value = 0

— Data saving code goes here if you need it
end)

This was a lengthy tutorial from me, my longest yet! If you want to watch more tutorials on how to script on Roblox, remember to subscribe to my channel.


but it doesn't work, help please thanks

0
I don't think you're gamer enough for this bro brokenVectors 525 — 4y
0
Oh yeah I know why it isn't working is because ReplicatedStorage doesn't exist brokenVectors 525 — 4y
0
oh ok, thanks I will Instance.new and use 2nd argument for parent starmaq 1290 — 4y
0
Try putting a wait at the top of the script. That is what daddy alvin taught me incapaz 195 — 4y
View all comments (3 more)
0
SACRIFICE YOUR SOUL TO THE SCRIPT GODS. THEY WILL SHOW YOU THE WAY TO BECOMING THE ULTIMATE SCRIPTER AND MAKE THE NEXT PIGGY. THEY WILL GIVE YOUR SOUL TO ALVINBLOX WHICH WILL GRANT HIM UNLIMITED POWERS. brokenVectors 525 — 4y
0
you need to remove the part that says "ShootEvent". this is a bad word and roblox doesnt like it so remove it now Tom_atoes 0 — 4y
0
have you tried turning it off and on again? Amiaa16 3227 — 4y

Locked by Amiaa16

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

4 answers

Log in to vote
3
Answered by
incapaz 195
4 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Try disabling and re-enabling the script.

wait(); -- daddy alvin's solution
script.Disabled = true; -- U NEED THE SEMICOLON OR ELSE NO COMPILE
script.Disabled = false;

This basically tells the ROBLOX.com servers to slap the script's face so it can wake up and start working.

If that doesn't work let me know.

0
This has a few issues, my answer fixes them all so accept mine kthxbye brokenVectors 525 — 4y
0
omg your so smart! starmaq 1290 — 4y
Ad
Log in to vote
2
Answered by 4 years ago

Please provide code with your answers. Simply posting an explanation does not help someone new to programming understand how to implement a concept programatically.

^ what incapaz said

0
Make sure to mark my post as the solution if it worked! brokenVectors 525 — 4y
Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
4 years ago

This question has been solved by the original poster.

^ what brokenVectors said

0
HOW DARE YOU STEAL MY SOLUTION YOU PLAGIARIST,,, brokenVectors 525 — 4y
Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
4 years ago

Omg thanks evreyone! Sorry I can't find answer button, I will accept later.