this script will only print 1 and 2 when activated. (they are near the top) Have no idea whats wrong, looks normal to me. Apparently something wrong with data.
--//Main Variables//--
local event = script.Parent.EPressed
local replicatedStorage = game:GetService("ReplicatedStorage")
local HookModel = replicatedStorage.Hook.Union
local GoldModel = replicatedStorage.HookGolden.Union
--//Script//--
event.OnServerEvent:Connect(function(Player,Action,MouseHit)
print("1")
--//Player Variables//--
local NumberOfHooks = Player:WaitForChild("NumberOfHooks")
local AmountOfHooks = NumberOfHooks:WaitForChild("Amount")
local DataManager = require(game:GetService("ReplicatedStorage").DataManager)
local data = DataManager:Get(Player)
--//Checks if hook is already out//--
if AmountOfHooks.Value == 0 then
print("2")
--//More variables//--
local char = Player.Character or Player.CharacterAdded:Wait()
local Hum = char:WaitForChild("Humanoid")
local HumRP = char:WaitForChild("HumanoidRootPart")
local TS = game:GetService("TweenService")
--//If key pressed is E then continue//--
if Action == "E" then
--//Diffrent Hooks//--
local GoldProjectile = GoldModel:Clone()
--//Default hook Script//--
if data then
print("3")
if data.GoldenHookEquipped.Value == true then --//Golden Hook script//--
GoldProjectile.Parent = workspace
GoldProjectile.CanCollide = false
GoldProjectile.CFrame = HumRP.CFrame * CFrame.new(0,3,0)
GoldProjectile.CFrame = CFrame.new(GoldProjectile.Position,MouseHit.p)
local Tween = TS:Create(GoldProjectile,TweenInfo.new(3),{CFrame = GoldProjectile.CFrame * CFrame.new(0,0,-130)})
Tween:Play()
GoldProjectile.Touched:Connect(function(Hit)
local db = false
if Hit.Name == "Union" then
if not db then
db = true
local HookPostition = GoldProjectile.Position
local NewHook = GoldModel:Clone()
NewHook.Parent = workspace
NewHook.Position = HookPostition
NewHook.Anchored = true
NewHook.Rotation = GoldProjectile.Rotation
NewHook.Name = "HookUsed"
local Rope2 = Instance.new("RopeConstraint")
Rope2.Attachment0 = NewHook.Attachment
Rope2.Attachment1 = Player.Character:FindFirstChild("Torso").BodyFrontAttachment
Rope2.Thickness = .2
Rope2.Visible = true
Rope2.Length = (NewHook.Position - Player.Character.HumanoidRootPart.Position).magnitude - 1
Rope2.Parent = NewHook
AmountOfHooks.Value = AmountOfHooks.Value + 1
end
end
GoldProjectile:Destroy()
db = false
end)
game.Debris:AddTag(GoldProjectile,2.5)
delay(.6,function()
local Tween = TS:Create(GoldProjectile,TweenInfo.new(0.3),{Transparency = 1})
Tween:Play()
if AmountOfHooks.Value <= 0 then
end
end)
end
end
else
print("4")
local HookProjectile = HookModel:Clone()
HookProjectile.Parent = workspace
HookProjectile.CanCollide = false
HookProjectile.CFrame = HumRP.CFrame * CFrame.new(0,3,0)
HookProjectile.CFrame = CFrame.new(HookProjectile.Position,MouseHit.p)
local Tween = TS:Create(HookProjectile,TweenInfo.new(3),{CFrame = HookProjectile.CFrame * CFrame.new(0,0,-130)})
Tween:Play()
HookProjectile.Touched:Connect(function(Hit)
local db = false
if Hit.Name == "Union" then
if not db then
db = true
local HookPostition = HookProjectile.Position
local NewHook = HookModel:Clone()
NewHook.Parent = workspace
NewHook.Position = HookPostition
NewHook.Anchored = true
NewHook.Rotation = HookProjectile.Rotation
NewHook.Name = "HookUsed"
local Rope2 = Instance.new("RopeConstraint")
Rope2.Attachment0 = NewHook.Attachment
Rope2.Attachment1 = Player.Character:FindFirstChild("Torso").BodyFrontAttachment
Rope2.Thickness = .2
Rope2.Visible = true
Rope2.Length = (NewHook.Position - Player.Character.HumanoidRootPart.Position ).magnitude - 1
local bodyGyro = Instance.new("BodyGyro")
bodyGyro.Parent = NewHook
Rope2.Parent = NewHook
AmountOfHooks.Value = AmountOfHooks.Value + 1
end
end
HookProjectile:Destroy()
db = false
end)
game.Debris:AddTag(HookProjectile,2.5)
delay(2.2,function()
local Tween = TS:Create(HookProjectile,TweenInfo.new(0.3),{Transparency = 1})
Tween:Play()
if AmountOfHooks.Value <= 0 then
end
end)
end
elseif AmountOfHooks.Value >= 1 then
end
end)