#scripting fix

1 messages · Page 1 of 1 (latest)

narrow patrol
#

i need help because my gui doesnt enable when i initiate the combat
`local Remotes = game.ReplicatedStorage:WaitForChild("RemoteEvents")

local StartTurnRemote = Remotes:WaitForChild("StartBattle")
local Camhandler = Remotes:WaitForChild("CamHandling")
local TurnCycleRemote = Remotes:WaitForChild("TurnCycleEvent")
local UIS = game:GetService("UserInputService")

local Monsters = require(game.ReplicatedStorage:WaitForChild("MonsterData"))

StartTurnRemote.OnServerEvent:Connect(function(player)
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

local mPos = character.HumanoidRootPart.Position

local spacing = 10
local allyPos = mPos + Vector3.new(0, 0, spacing*3.5)
local enemyPos = mPos + Vector3.new(0, 0, spacing)

local ally = character
local enemy = Monsters.GetMonster("Specter")

ally.PrimaryPart = ally.HumanoidRootPart
enemy.PrimaryPart = enemy.HumanoidRootPart

ally:SetPrimaryPartCFrame(CFrame.new(allyPos))
enemy:SetPrimaryPartCFrame(CFrame.new(enemyPos))

local direction = character.HumanoidRootPart.Position - enemy.HumanoidRootPart.Position
local lookAtCFrame = CFrame.new(enemyPos, enemyPos + direction)

enemy:SetPrimaryPartCFrame(lookAtCFrame)


ally.Parent = workspace.Combat
enemy.Parent = workspace.Combat

TurnCycleRemote:FireClient(player, "Planning")


local idleanim = Instance.new("Animation")
idleanim.AnimationId = "rbxassetid://99791378966063"
local animtrack = humanoid:LoadAnimation(idleanim)
animtrack:Play()
animtrack.Looped = true

humanoid.PlatformStand = true
humanoid.JumpHeight = 0

local rootpart = character:WaitForChild("HumanoidRootPart")
rootpart.Anchored = true -- prevents the player from falling

local combatui = game.StarterGui.CombatUI
local runn = combatui.RUN
local attackk = combatui.ATTACK
combatui.Enabled = true

end)
`

that was server side

#

This is local:

`local Remotes = game.ReplicatedStorage:WaitForChild("RemoteEvents")
local TurnCycleEvent = Remotes:WaitForChild("TurnCycleEvent")
local player = game.Players.LocalPlayer
local combatui = game.StarterGui.CombatUI
local runn = combatui.RUN.TextLabel
local attackk = combatui.ATTACK.TextLabel

TurnCycleEvent.OnClientEvent:Connect(function(currentPhase)
if currentPhase == "Planning" then
print("Planning Phase")
combatui.Enabled = true

elseif currentPhase == "Attacking" then
    print("Fighting Phase")
    
    
end

end)`

#

the problem is in the local script

#

when i do combatui.Enabled = true it doesnt work

#

it just skips it

wheat iron
#

change: local combatui = game.StarterGui.CombatUI

#

to: local combatui = player:WaitForChild("PlayerGui"):WaitForChild("CombatUI")

#

np