# Can't assign slate button pointer to global variable

**URL:** <https://forums.unrealengine.com/t/cant-assign-slate-button-pointer-to-global-variable/435410>\
**Category:** UI\
**Tags:** newobject, unreal-engine, crash, slate, CPP, question, UMG\
**Created:** [October 11, 2018, 1:27pm UTC](https://forums.unrealengine.com/t/cant-assign-slate-button-pointer-to-global-variable/435410 "2018-10-11T13:27:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FeirisNyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FeirisNyan](https://forums.unrealengine.com/u/FeirisNyan)\
**Post date:** [October 11, 2018, 1:27pm UTC](https://forums.unrealengine.com/t/cant-assign-slate-button-pointer-to-global-variable/435410/1 "2018-10-11T13:27:14Z")

</div>

Crashes when clicked on created button with LOG error:

**LogScript: Warning: Script Msg: No world was found for object (/Engine/Transient.UnrealEdEngine\_0:GameInstance\_0.PlayerHUD\_C\_0.Butt\_0) passed in to UEngine::GetWorldFromContextObject().**

```
Butt.cpp
void UButt::OnClick()
{
	Cast<AThirdPersCharacter>(UGameplayStatics::GetPlayerPawn(this, 0))->OnClicku(this);
}

void UMyUserWidget::NativeConstruct()
{
	Super::NativeConstruct();
	UniformGridPanel = Cast<UUniformGridPanel>(GetWidgetFromName("UniformGridPanel_0"));
	NewObject<UButt>();
	UniformGridPanel->AddChild(Butt);
}

ThirdPersCharacter.h
UPROPERTY(BlueprintReadWrite)
	UButt* PressedButton;

ThirdPersCharacter.cpp
void AThirdPersCharacter::OnClicku(UButt* ButtRef)
{
	UButt* TempUButt = ButtRef;//no crash
	CurrentButton = ButtRef;//crash

```

What should i do?
